-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cirq-core target gatesets: accept additional gates to keep untouched. (…
…#5445) Builds on top of #5429 The internal gate representation for `additional_gates` is updated to match `cirq.Gateset`: * Equality check uses GateFamily representation. Otherwise different representations of the gate will not be considered equal. * JSON uses GateFamily representation. * repr uses the representation passed in via the constructor. `assert_optimizes` in `cz_gateset_test.py` is updated to take in an optional `additional_gates` instead, to exercise CZTargetGateset constructor's defaulting logic. No tests are added since `additional_gates` need to be set in existing tests after `ignore_errors` is set to False. @tanujkhattar
- Loading branch information
Showing
9 changed files
with
314 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 16 additions & 2 deletions
18
cirq-core/cirq/protocols/json_test_data/CZTargetGateset.repr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
[ | ||
cirq.CZTargetGateset(atol=1e-06, allow_partial_czs=False), | ||
cirq.CZTargetGateset(atol=1e-08, allow_partial_czs=True), | ||
cirq.CZTargetGateset(atol=1e-06, allow_partial_czs=False, additional_gates=[]), | ||
cirq.CZTargetGateset(atol=1e-08, allow_partial_czs=True, additional_gates=[]), | ||
cirq.CZTargetGateset( | ||
atol=1e-06, | ||
allow_partial_czs=True, | ||
additional_gates=[ | ||
(cirq.ISWAP**0.5), | ||
cirq.ops.common_gates.XPowGate, | ||
cirq.GateFamily( | ||
gate=cirq.ops.common_gates.ZPowGate, | ||
ignore_global_phase=True, | ||
tags_to_accept=frozenset(), | ||
tags_to_ignore=frozenset(), | ||
), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 22 additions & 3 deletions
25
cirq-core/cirq/protocols/json_test_data/SqrtIswapTargetGateset.repr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
[ | ||
cirq.SqrtIswapTargetGateset( | ||
atol=1e-08, required_sqrt_iswap_count=None, use_sqrt_iswap_inv=False | ||
atol=1e-08, required_sqrt_iswap_count=None, use_sqrt_iswap_inv=False, additional_gates=[] | ||
), | ||
cirq.SqrtIswapTargetGateset( | ||
atol=1e-08, required_sqrt_iswap_count=1, use_sqrt_iswap_inv=False, additional_gates=[] | ||
), | ||
cirq.SqrtIswapTargetGateset( | ||
atol=1e-06, required_sqrt_iswap_count=2, use_sqrt_iswap_inv=True, additional_gates=[] | ||
), | ||
cirq.SqrtIswapTargetGateset( | ||
atol=1e-08, | ||
required_sqrt_iswap_count=None, | ||
use_sqrt_iswap_inv=False, | ||
additional_gates=[ | ||
cirq.CZ, | ||
cirq.ops.common_gates.XPowGate, | ||
cirq.GateFamily( | ||
gate=cirq.ops.common_gates.ZPowGate, | ||
ignore_global_phase=True, | ||
tags_to_accept=frozenset(), | ||
tags_to_ignore=frozenset(), | ||
), | ||
], | ||
), | ||
cirq.SqrtIswapTargetGateset(atol=1e-08, required_sqrt_iswap_count=1, use_sqrt_iswap_inv=False), | ||
cirq.SqrtIswapTargetGateset(atol=1e-06, required_sqrt_iswap_count=2, use_sqrt_iswap_inv=True), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.