Skip to content

Commit

Permalink
Mark ProjectorSum class as unhashable (#6701)
Browse files Browse the repository at this point in the history
ProjectorSum stores data in a mutable LinearDict which is not hashable.
LinearDict also does not pickle, because by default it has a
lambda-function attribute.

This excludes ProjectorSum from the `test_hash_from_pickle` test.

Resolves #6674
  • Loading branch information
pavoljuhas authored Aug 8, 2024
1 parent 5377fff commit e2e8aef
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/linear_combinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ def _projector_string_from_projector_dict(projector_dict, coefficient=1.0):
return ProjectorString(dict(projector_dict), coefficient)


@value.value_equality(approximate=True)
@value.value_equality(approximate=True, unhashable=True)
class ProjectorSum:
"""List of mappings representing a sum of projector operators."""

Expand Down
2 changes: 0 additions & 2 deletions cirq-core/cirq/protocols/hash_from_pickle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
"cirq/protocols/json_test_data/sympy.pi.json",
# RigettiQCSAspenDevice does not pickle
"cirq_rigetti/json_test_data/RigettiQCSAspenDevice.json",
# TODO(#6674,pavoljuhas) - fix pickling of ProjectorSum
"cirq/protocols/json_test_data/ProjectorSum.json",
)


Expand Down

0 comments on commit e2e8aef

Please sign in to comment.