Skip to content

Commit d440d10

Browse files
committed
API: drop optional bounds from Parameter.setValue
Move setup of upper and lower bounds from `Parameter.setValue()` to a new `Parameter.boundRange()` method. The setValue-with-bounds does not seem to be used at all. This fixes the ellipsoidsas.py example.
1 parent ff6b78a commit d440d10

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

src/diffpy/srfit/fitbase/parameter.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(self, name, value = None, const = False):
7171
Argument.__init__(self, name, value, const)
7272
return
7373

74-
def setValue(self, val, lb = None, ub = None):
74+
def setValue(self, val):
7575
"""Set the value of the Parameter and the bounds.
7676
7777
val -- The value to assign.
@@ -84,8 +84,6 @@ def setValue(self, val, lb = None, ub = None):
8484
8585
"""
8686
Argument.setValue(self, val)
87-
if lb is not None: self.bounds[0] = lb
88-
if ub is not None: self.bounds[1] = ub
8987
return self
9088

9189
def setConst(self, const = True, value = None):
@@ -105,6 +103,22 @@ def setConst(self, const = True, value = None):
105103
self.setValue(value)
106104
return self
107105

106+
107+
def boundRange(self, lb=None, ub=None):
108+
"""Set lower and upper bound of the Parameter.
109+
110+
lb -- The lower bound for the bounds list.
111+
ub -- The upper bound for the bounds list.
112+
113+
Returns self so that mutators can be chained.
114+
"""
115+
if lb is not None:
116+
self.bounds[0] = lb
117+
if ub is not None:
118+
self.bounds[1] = ub
119+
return self
120+
121+
108122
def boundWindow(self, lr = 0, ur = None):
109123
"""Create bounds centered on the current value of the Parameter.
110124
@@ -203,8 +217,8 @@ def _observers(self):
203217
# wrap Parameter methods to use the target object ------------------------
204218

205219
@wraps(Parameter.setValue)
206-
def setValue(self, val, lb=None, ub=None):
207-
return self.par.setValue(val, lb, ub)
220+
def setValue(self, val):
221+
return self.par.setValue(val)
208222

209223

210224
@wraps(Parameter.getValue)
@@ -217,6 +231,11 @@ def setConst(self, const=True, value=None):
217231
return self.par.setConst(const, value)
218232

219233

234+
@wraps(Parameter.boundRange)
235+
def boundRange(self, lb=None, ub=None):
236+
return self.par.boundRange(lb, ub)
237+
238+
220239
@wraps(Parameter.boundWindow)
221240
def boundWindow(self, lr=0, ur=None):
222241
return self.par.boundWindow(lr, ur)
@@ -300,15 +319,11 @@ def getValue(self):
300319
"""Get the value of the Parameter."""
301320
return self.getter(self.obj)
302321

303-
def setValue(self, value, lb = None, ub = None):
322+
def setValue(self, value):
304323
"""Set the value of the Parameter."""
305324
if value != self.getValue():
306325
self.setter(self.obj, value)
307326
self.notify()
308-
309-
if lb is not None: self.bounds[0] = lb
310-
if ub is not None: self.bounds[1] = ub
311-
312327
return self
313328

314329
# End class ParameterAdapter

0 commit comments

Comments
 (0)