from qnet import (
    One, Zero, ZeroOperator, IdentityOperator, ZeroSuperOperator,
    IdentitySuperOperator, ZeroKet, TrivialKet, FullSpace, TrivialSpace,
    CIdentity, CircuitZero)


def test_neutral_elements():
    """test the properties of the neutral elements in the quantum algebras.
    This tests the resolution of #63

    *Only* the scalar neutral elements compare to and hash as 0 and 1. The
    neutral elements of all other algebras are "unique" and don't compare to 0
    and 1. Elements of a quantum algebra have an is_zero attribute
    """
    assert One == 1
    assert One is not 1
    assert hash(One) == hash(1)
    assert Zero == 0
    assert Zero is not 0
    assert hash(Zero) == hash(0)
    assert Zero.is_zero

    assert IdentityOperator != 1
    assert hash(IdentityOperator) != hash(1)
    assert ZeroOperator != 0
    assert hash(ZeroOperator) != hash(0)
    assert ZeroOperator.is_zero

    assert IdentitySuperOperator != 1
    assert hash(IdentitySuperOperator) != hash(1)
    assert ZeroSuperOperator != 0
    assert hash(ZeroSuperOperator) != hash(0)
    assert ZeroSuperOperator.is_zero

    assert TrivialKet != 1
    assert hash(TrivialKet) != hash(1)
    assert ZeroKet != 0
    assert hash(ZeroKet) != hash(0)
    assert ZeroKet.is_zero

    #  the remainder are not quantum algebra elements, to they don't have
    #  is_zero
    assert FullSpace != 1
    assert hash(FullSpace) != hash(1)
    assert TrivialSpace != 0
    assert hash(TrivialSpace) != hash(0)

    assert CIdentity != 1
    assert hash(CIdentity) != hash(1)
    assert CircuitZero != 0
    assert hash(CircuitZero) != hash(0)

Test equality and hashing of neutral elements
Test equality and hashing of neutral elements

With the implementation of the scalar algebra it turns out that the way
to go is to have only the scalar Zero and One equal to 0 and 1. In every
other algebra, the neutral elements have no relation to the scalar 0 and
1, or to the neutral elements of other algebras.

Hoever, elements of "quantum" algebras (anything that has a Hilbert
space, including in fact the scalar algebra on the TrivialSpace) have an
is_zero attribute to compare to the abstract zero.

This closes #63
