Skip to content

Commit

Permalink
refactor(measurement): removed nrange from scans, now replaced with i…
Browse files Browse the repository at this point in the history
…terator where applicable.
  • Loading branch information
rsbrost committed Aug 20, 2024
1 parent 25be9e7 commit eb0d8a3
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pyscan/measurement/scans.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def check_same_length(self):

# This must be a method and not an attribute as iterators can only be used once
def iterator(self):
return iter(self.nrange)
return iter(range(self.n))


class PropertyScan(AbstractScan):
Expand Down Expand Up @@ -78,12 +78,10 @@ def check_same_length(self):
if len(list(self.scan_dict.keys())) > 0:
if same_length(list(self.scan_dict.values())):
self.n = len(list(self.scan_dict.values())[0]) # self.n is the length of the input_dict arrays.
self.nrange = range(self.n)
else:
assert 0, 'Values are not of the same length'
else:
self.n = 1 # n=1 is required to allow the run() function to proceed atleast once.
self.nrange = range(1)


class FunctionScan(AbstractScan):
Expand Down Expand Up @@ -112,7 +110,6 @@ def __init__(self, function, values, dt=0):
self.dt = dt
self.i = 0
self.n = len(values)
self.nrange = range(self.n)

def iterate(self, index, devices):
'''
Expand Down Expand Up @@ -155,7 +152,6 @@ def __init__(self, nrepeat, dt=0):
self.dt = dt

self.n = nrepeat
self.nrange = range(self.n)

self.i = 0

Expand Down Expand Up @@ -192,8 +188,7 @@ def __init__(self, n_average, dt=0):

self.scan_dict = {}
self.n = n_average
self.nrange = range(self.n)
self.scan_dict['average'] = list(self.nrange)
self.scan_dict['average'] = list(self.iterator())
self.device_names = ['average']
self.i = 0
self.dt = dt
Expand Down

0 comments on commit eb0d8a3

Please sign in to comment.