Skip to content

Commit ba7682d

Browse files
committed
Add missing alternate parameter to PowerTermGenerator
1 parent 654f1c3 commit ba7682d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

scanpointgenerator/generators/powertermgenerator.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class PowerTermGenerator(Generator):
77
"""Generate a line of points according to the function y = ((x-x_focus)/divisor)**exponent + focus"""
88

9-
def __init__(self, axis, units, start, stop, focus, exponent, divisor):
9+
def __init__(self, axis, units, start, stop, focus, exponent, divisor, alternate=False):
1010
"""
1111
Args:
1212
axis (str): The scannable axis e.g. "dcm_energy"
@@ -37,6 +37,8 @@ def __init__(self, axis, units, start, stop, focus, exponent, divisor):
3737
self.xf = self.find_xf()
3838
self.size = int(self._inv_fn(stop))+1
3939

40+
self.alternate = alternate
41+
4042
def prepare_arrays(self, index_array):
4143
arrays = dict()
4244
arrays[self.axes[0]] = self._fn(index_array)
@@ -75,6 +77,7 @@ def to_dict(self):
7577
d['focus'] = self.focus
7678
d['exponent'] = self.exponent
7779
d['divisor'] = self.divisor
80+
d['alternate'] = self.alternate
7881

7982
return d
8083

@@ -87,8 +90,9 @@ def from_dict(cls, d):
8790
exponent = d['exponent']
8891
divisor = d['divisor']
8992
focus = d['focus']
93+
alternate = d['alternate']
9094

91-
return cls(axes, units, start, stop, focus, exponent, divisor)
95+
return cls(axes, units, start, stop, focus, exponent, divisor, alternate)
9296

9397

9498
def get_suitable_sign(start, stop, focus, exponent):

tests/test_generators/test_powertermgenerator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def test_to_dict(self):
124124
expected['focus'] = 280.
125125
expected['exponent'] = 3
126126
expected['divisor'] = 5.
127+
expected['alternate'] = False
127128

128129
self.assertEquals(g.to_dict(), expected)
129130

@@ -136,6 +137,7 @@ def test_from_dict(self):
136137
_dict['focus'] = 280.
137138
_dict['exponent'] = 3
138139
_dict['divisor'] = 20.5
140+
_dict['alternate'] = False
139141

140142
units_dict = dict()
141143
units_dict['x'] = "cm"

0 commit comments

Comments
 (0)