Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cirq-core/cirq/ops/gateset.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,17 @@ def _value_equality_values_(self) -> Any:
)

def _json_dict_(self) -> Dict[str, Any]:
return {
d: Dict[str, Any] = {
'gate': self._gate_json(),
'name': self.name,
'description': self.description,
'ignore_global_phase': self._ignore_global_phase,
'tags_to_accept': list(self._tags_to_accept),
'tags_to_ignore': list(self._tags_to_ignore),
}
if self._tags_to_accept:
d['tags_to_accept'] = list(self._tags_to_accept)
if self._tags_to_ignore:
d['tags_to_ignore'] = list(self._tags_to_ignore)
return d

@classmethod
def _from_json_dict_(
Expand Down
12 changes: 3 additions & 9 deletions cirq-core/cirq/protocols/json_test_data/CZTargetGateset.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,21 @@
},
"name": "Instance GateFamily: ISWAP**0.5",
"description": "Accepts `cirq.Gate` instances `g` s.t. `g == ISWAP**0.5`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
"gate": "XPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.XPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.XPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
"gate": "ZPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.ZPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.ZPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
}
]
}
Expand Down
12 changes: 3 additions & 9 deletions cirq-core/cirq/protocols/json_test_data/GateFamily.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"gate": "XPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.XPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.XPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
Expand All @@ -17,9 +15,7 @@
},
"name": "XFamily",
"description": "Just the X gate.",
"ignore_global_phase": false,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": false
},
{
"cirq_type": "GateFamily",
Expand All @@ -29,16 +25,14 @@
"ignore_global_phase": true,
"tags_to_accept": [
"physical_z"
],
"tags_to_ignore": []
]
},
{
"cirq_type": "GateFamily",
"gate": "ZPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.ZPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.ZPowGate)`\nIgnored tags: ['physical_z']",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": [
"physical_z"
]
Expand Down
16 changes: 4 additions & 12 deletions cirq-core/cirq/protocols/json_test_data/Gateset.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"gate": "YPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.YPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.YPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "AnyUnitaryGateFamily",
Expand All @@ -24,9 +22,7 @@
},
"name": "Instance GateFamily: X",
"description": "Accepts `cirq.Gate` instances `g` s.t. `g == X`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
}
],
"name": null,
Expand All @@ -44,18 +40,14 @@
},
"name": "Instance GateFamily: X",
"description": "Accepts `cirq.Gate` instances `g` s.t. `g == X`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
"gate": "YPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.YPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.YPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "AnyUnitaryGateFamily",
Expand Down
40 changes: 10 additions & 30 deletions cirq-core/cirq/protocols/json_test_data/GridDeviceMetadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,21 @@
"gate": "XPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.XPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.XPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
"gate": "YPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.YPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.YPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
"gate": "ZPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.ZPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.ZPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
Expand All @@ -125,9 +119,7 @@
},
"name": "Instance GateFamily: CZ",
"description": "Accepts `cirq.Gate` instances `g` s.t. `g == CZ`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
Expand All @@ -138,9 +130,7 @@
},
"name": "Instance GateFamily: ISWAP**0.5",
"description": "Accepts `cirq.Gate` instances `g` s.t. `g == ISWAP**0.5`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
}
],
"name": null,
Expand All @@ -157,9 +147,7 @@
},
"name": "Instance GateFamily: ISWAP**0.5",
"description": "Accepts `cirq.Gate` instances `g` s.t. `g == ISWAP**0.5`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "Duration",
Expand All @@ -176,9 +164,7 @@
},
"name": "Instance GateFamily: CZ",
"description": "Accepts `cirq.Gate` instances `g` s.t. `g == CZ`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "Duration",
Expand All @@ -191,9 +177,7 @@
"gate": "XPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.XPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.XPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "Duration",
Expand All @@ -206,9 +190,7 @@
"gate": "YPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.YPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.YPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "Duration",
Expand All @@ -221,9 +203,7 @@
"gate": "ZPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.ZPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.ZPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "Duration",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,21 @@
},
"name": "Instance GateFamily: CZ",
"description": "Accepts `cirq.Gate` instances `g` s.t. `g == CZ`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
"gate": "XPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.XPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.XPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
"gate": "ZPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.ZPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.ZPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
}
]
}
Expand Down
40 changes: 10 additions & 30 deletions cirq-google/cirq_google/json_test_data/cirq.google.GridDevice.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,21 @@
"gate": "XPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.XPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.XPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
"gate": "YPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.YPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.YPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
"gate": "ZPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.ZPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.ZPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
Expand All @@ -127,9 +121,7 @@
},
"name": "Instance GateFamily: CZ",
"description": "Accepts `cirq.Gate` instances `g` s.t. `g == CZ`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "GateFamily",
Expand All @@ -140,9 +132,7 @@
},
"name": "Instance GateFamily: ISWAP**0.5",
"description": "Accepts `cirq.Gate` instances `g` s.t. `g == ISWAP**0.5`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
}
],
"name": null,
Expand All @@ -159,9 +149,7 @@
},
"name": "Instance GateFamily: ISWAP**0.5",
"description": "Accepts `cirq.Gate` instances `g` s.t. `g == ISWAP**0.5`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "Duration",
Expand All @@ -178,9 +166,7 @@
},
"name": "Instance GateFamily: CZ",
"description": "Accepts `cirq.Gate` instances `g` s.t. `g == CZ`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "Duration",
Expand All @@ -193,9 +179,7 @@
"gate": "XPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.XPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.XPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "Duration",
Expand All @@ -208,9 +192,7 @@
"gate": "YPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.YPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.YPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "Duration",
Expand All @@ -223,9 +205,7 @@
"gate": "ZPowGate",
"name": "Type GateFamily: cirq.ops.common_gates.ZPowGate",
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.ZPowGate)`",
"ignore_global_phase": true,
"tags_to_accept": [],
"tags_to_ignore": []
"ignore_global_phase": true
},
{
"cirq_type": "Duration",
Expand Down