Various exceptions that can be raised by qitensor functions.
Bases: qitensor.exceptions.HilbertError
Raised when an operation would result in an output with two copies of a HilbertAtom.
>>> from qitensor import qubit
>>> ha = qubit('a')
>>> ha * ha
Traceback (most recent call last):
...
DuplicatedSpaceError: '|a>'
>>> x = ha.array()
>>> x * x
Traceback (most recent call last):
...
DuplicatedSpaceError: '|a>'
Bases: exceptions.Exception
The generic exception used by qitensor. All of this package’s other exceptions derive from this one.
Bases: qitensor.exceptions.HilbertError, exceptions.LookupError
Raised when an invalid array subscript is given.
>>> from qitensor import qubit
>>> ha = qubit('a')
>>> x = ha.array()
>>> x[2]
Traceback (most recent call last):
...
HilbertIndexError: 'Index set for |a> does not contain 2'
>>> x[{ ha.H: 0 }]
Traceback (most recent call last):
...
HilbertIndexError: 'Hilbert space not part of this array: <a|'
Bases: qitensor.exceptions.HilbertError, exceptions.ValueError
Raised when an array is not the right shape for the requested operation.
Bases: qitensor.exceptions.HilbertError
Raised when two HilbertAtoms have the same label but different properties, or when the HilbertSpace requested for an operation doesn’t match that of an array.
Bases: qitensor.exceptions.HilbertError
Raised when a bra space is given to an operation that only works on ket spaces.