Skip to content

Add UNIT_SWEEP as an alias for UnitSweep (#6518) #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2024
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
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