-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Environment
- Qiskit Terra version: dd7f939
- Python version: 3.10.8
- Operating system: Arch Linux
What is happening?
Objects which compare equal must have the same hash value; see https://docs.python.org/3/reference/datamodel.html#object.hash. This property is violated by Parameter.
How can we reproduce the issue?
from qiskit.circuit import Parameter
a = Parameter("a")
aa = a + 0
print(a == aa)
print(hash(a) == hash(aa))
True
False
Note that a
has type Parameter but aa
has type ParameterExpression
What should happen?
Any one of the following is acceptable in theory:
a == aa
andhash(a) == hash(aa)
both evaluate toTrue
.a == aa
andhash(a) == hash(aa)
both evaluate toFalse
.hash(a)
raisesTypeError: unhashable type
Any suggestions?
Another option would be to deprecate Parameter
and instead use sympy.Symbol
directly.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working