Skip to content

Commit afab09b

Browse files
rsbrosti-am-mounce
authored andcommitted
chore: now forcing legacy naming conventions to fail. Note: this could cause issues with trying to load and rerun old experiments. The use of loops should now be replaced with scans, the use of sweep with experiment, and the use of metasweep with abstractexperiment.
1 parent d97fa60 commit afab09b

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

pyscan/measurement/abstract_experiment.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ class MetaSweep(AbstractExperiment):
294294
Present for backwards compatibility. Renamed to :class:`.AbstractExperiment`.
295295
'''
296296

297-
warning_msg = ("Use of legacy nomenclature detected but no longer supported, use at your own risk!\n"
297+
warning_msg = ("Use of legacy nomenclature detected but no longer supported.\n"
298298
+ "You entered MetaSweep, use AbstractExperiment instead.")
299-
print(f"\033[93m*** WARNING! ***: {warning_msg} \033[0m")
299+
raise DeprecationWarning(f"\033[93m*** WARNING! ***: {warning_msg} \033[0m")
300+
assert False, f"\033[93m*** WARNING! ***: {warning_msg} \033[0m"

pyscan/measurement/experiment.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ class Sweep(Experiment):
272272
Present for backwards compatibility. Renamed to :class:`.Experiment`.
273273
'''
274274

275-
warning_msg = ("Use of legacy nomenclature detected but no longer supported, use at your own risk!\n"
275+
warning_msg = ("Use of legacy nomenclature detected but no longer supported.\n"
276276
+ "You entered Sweep, use Experiment instead.")
277-
print(f"\033[93m*** WARNING! ***: {warning_msg} \033[0m")
277+
raise DeprecationWarning(f"\033[93m*** WARNING! ***: {warning_msg} \033[0m")
278+
assert False, f"\033[93m*** WARNING! ***: {warning_msg} \033[0m"

pyscan/measurement/run_info.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ def has_average_scan(self):
195195

196196
return self._has_average_scan
197197

198-
# These property's are strictly for backwards compatibility with old pyscan naming convention.
198+
####################### LEGACY SECTION ########################
199+
# This section is set up to alert users who try to use legacy nomenclature
200+
# of the updated naming convention that they must use instead.
199201
@property
200202
def loop0(self):
201203
legacy_warning()
@@ -265,6 +267,7 @@ def drop(array, index):
265267

266268

267269
def legacy_warning():
268-
warning_msg = ("Use of legacy nomenclature detected but no longer supported, use at your own risk!\n"
270+
warning_msg = ("Use of legacy nomenclature detected but no longer supported.\n"
269271
+ "You entered 'loop', use 'scan' instead.")
270-
print(f"\033[93m*** WARNING! ***: {warning_msg} \033[0m")
272+
raise DeprecationWarning(f"\033[93m*** WARNING! ***: {warning_msg} \033[0m")
273+
assert False, f"\033[93m*** WARNING! ***: {warning_msg} \033[0m"

test/legacy/test_legacy.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
import pyscan as ps
2+
import pytest
23

34

45
def test_legacy():
6+
'''
7+
Ensure that legacy naming convention fails.
8+
'''
59
devices = ps.ItemAttribute()
610
runinfo = ps.RunInfo()
7-
sweep = ps.Sweep(runinfo, devices)
8-
9-
err_msg = "Legacy nomenclature failed. Sweep not initialized as Experiment or MetaSweep not as Abstract Experiment."
10-
assert isinstance(sweep, ps.Experiment), err_msg
11+
with pytest.raises(Exception):
12+
runinfo.loop0 = ps.PropertyScan({'v1': ps.drange(0, 0.1, 0.1)}, 'voltage')
13+
with pytest.raises(Exception):
14+
runinfo.loop1 = ps.PropertyScan({'v1': ps.drange(0, 0.1, 0.1)}, 'voltage')
15+
with pytest.raises(Exception):
16+
runinfo.loop2 = ps.PropertyScan({'v1': ps.drange(0, 0.1, 0.1)}, 'voltage')
17+
with pytest.raises(Exception):
18+
runinfo.loop3 = ps.PropertyScan({'v1': ps.drange(0, 0.1, 0.1)}, 'voltage')
19+
with pytest.raises(Exception):
20+
sweep = ps.Sweep(runinfo, devices)
21+
assert isinstance(sweep, ps.Experiment)

0 commit comments

Comments
 (0)