Skip to content

is_native_neutral_atom_gate crashes with TypeError when checking unhashable gates #7941

@zczhong149-art

Description

@zczhong149-art

Describe the issue

The utility function is_native_neutral_atom_gate raises a TypeError when passed a UniformSuperpositionGate.

Explain how to reproduce the bug or problem

import cirq
from cirq.neutral_atoms import is_native_neutral_atom_gate
from cirq.ops import UniformSuperpositionGate

# Create an unhashable gate
gate = UniformSuperpositionGate(m_value=3, num_qubits=2)

# This call triggers the TypeError
print(is_native_neutral_atom_gate(gate))
Details

Traceback (most recent call last):
File "trigger.py", line 6, in
is_native_neutral_atom_gate(gate)
File ".../cirq/neutral_atoms/convert_to_neutral_atom_gates.py", line 32, in is_native_neutral_atom_gate
return gate in neutral_atom_devices.neutral_atom_gateset()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../cirq/ops/gateset.py", line 419, in contains
if g in self._instance_gate_families:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'UniformSuperpositionGate'

Tell us the version of Cirq where this happens

1.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bug-reportSomething doesn't seem to work.triage/discussNeeds decision / discussion, bring these up during Cirq Cynque

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions