You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using integers as labels e.g. for BasisKet should not be allowed (or rather, an integer label should be converted via str in the __init__ routine). Allowing integers makes it tempting to do arithmetic on the labels. However, any code that does this will fail if the labels are actually strings! Instead, numerical indices should be obtained via an index method / property
The text was updated successfully, but these errors were encountered:
Actually, there are reasons for supporting both numeric indices and string labels: For numeric indices, we can do a number of operations without having to specify the basis (or dimension) of the underlying Hilbert space. For example, we can apply a Creation operator.
However, we need a strict and explicit interface for handling this: BasisKet can be instantiated with a label_or_index parameter. If this parameter is an int, it is taken as the index, if it is a string, as the label. Add an index property which is different from the label property (always a string!)
Using integers as labels e.g. for
BasisKet
should not be allowed (or rather, an integer label should be converted viastr
in the__init__
routine). Allowing integers makes it tempting to do arithmetic on the labels. However, any code that does this will fail if the labels are actually strings! Instead, numerical indices should be obtained via anindex
method / propertyThe text was updated successfully, but these errors were encountered: