Skip to content

Commit edda3a5

Browse files
authored
Add UNIT_SWEEP as an alias for UnitSweep (#6518)
Since this is a singleton, it should use constant naming. Since it should also stay consistent with other Sweeps (and for backwards compatibility), we will keep the old name as well. Fixes: #5617
1 parent 83382ae commit edda3a5

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

cirq-core/cirq/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@
509509
to_sweeps,
510510
Result,
511511
UnitSweep,
512+
UNIT_SWEEP,
512513
Zip,
513514
ZipLongest,
514515
)

cirq-core/cirq/protocols/json_test_data/spec.py

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
'StateVectorStepResult',
110110
'StepResultBase',
111111
'UnitSweep',
112+
'UNIT_SWEEP',
112113
'NamedTopology',
113114
# protocols:
114115
'HasJSONNamespace',

cirq-core/cirq/study/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
Points,
3737
Product,
3838
Sweep,
39+
UNIT_SWEEP,
3940
UnitSweep,
4041
Zip,
4142
ZipLongest,

cirq-core/cirq/study/sweeps.py

+4
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ def _json_dict_(self) -> Dict[str, Any]:
205205
UnitSweep = _Unit()
206206
document(UnitSweep, """The singleton sweep with no parameters.""")
207207

208+
# Alternate name to designate as a constant.
209+
UNIT_SWEEP = UnitSweep
210+
document(UNIT_SWEEP, """The singleton sweep with no parameters.""")
211+
208212

209213
class Product(Sweep):
210214
"""Cartesian product of one or more sweeps.

cirq-core/cirq/study/sweeps_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ def test_equality():
232232

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

235+
# Test singleton
236+
assert cirq.UNIT_SWEEP is cirq.UnitSweep
237+
235238
# Simple sweeps with the same key are equal to themselves, but different
236239
# from each other even if they happen to contain the same points.
237240
et.make_equality_group(lambda: cirq.Linspace('a', 0, 10, 11))

0 commit comments

Comments
 (0)