Skip to content

Commit

Permalink
Merge pull request #1 from quantumlib/main
Browse files Browse the repository at this point in the history
Add UNIT_SWEEP as an alias for UnitSweep (quantumlib#6518)
  • Loading branch information
senecameeks authored Mar 22, 2024
2 parents a99a93e + edda3a5 commit d2cf0db
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions cirq-core/cirq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@
to_sweeps,
Result,
UnitSweep,
UNIT_SWEEP,
Zip,
ZipLongest,
)
Expand Down
1 change: 1 addition & 0 deletions cirq-core/cirq/protocols/json_test_data/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
'StateVectorStepResult',
'StepResultBase',
'UnitSweep',
'UNIT_SWEEP',
'NamedTopology',
# protocols:
'HasJSONNamespace',
Expand Down
1 change: 1 addition & 0 deletions cirq-core/cirq/study/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
Points,
Product,
Sweep,
UNIT_SWEEP,
UnitSweep,
Zip,
ZipLongest,
Expand Down
4 changes: 4 additions & 0 deletions cirq-core/cirq/study/sweeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ def _json_dict_(self) -> Dict[str, Any]:
UnitSweep = _Unit()
document(UnitSweep, """The singleton sweep with no parameters.""")

# Alternate name to designate as a constant.
UNIT_SWEEP = UnitSweep
document(UNIT_SWEEP, """The singleton sweep with no parameters.""")


class Product(Sweep):
"""Cartesian product of one or more sweeps.
Expand Down
3 changes: 3 additions & 0 deletions cirq-core/cirq/study/sweeps_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ def test_equality():

et.add_equality_group(cirq.UnitSweep, cirq.UnitSweep)

# Test singleton
assert cirq.UNIT_SWEEP is cirq.UnitSweep

# Simple sweeps with the same key are equal to themselves, but different
# from each other even if they happen to contain the same points.
et.make_equality_group(lambda: cirq.Linspace('a', 0, 10, 11))
Expand Down

0 comments on commit d2cf0db

Please sign in to comment.