Skip to content

Commit

Permalink
Now allowing lower and upper bounds of angle parameters to be any val…
Browse files Browse the repository at this point in the history
…ue in the range -inf to +inf
  • Loading branch information
mlauer154 committed Feb 12, 2024
1 parent 33d8dd0 commit 86f641d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
6 changes: 0 additions & 6 deletions pymead/core/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,9 @@ def rad(self):
return self._value

def set_lower(self, lower: float):
if lower < 0.0:
lower = 0.0

return super().set_lower(UNITS.convert_angle_to_base(lower, self.unit()))

def set_upper(self, upper: float):
if upper > UNITS.convert_angle_from_base(2 * np.pi, self.unit()):
upper = UNITS.convert_angle_from_base(2 * np.pi, self.unit())

return super().set_upper(UNITS.convert_angle_to_base(upper, self.unit()))

def set_value(self, value: float, updated_objs: typing.List[PymeadObj] = None, bounds_normalized: bool = False):
Expand Down
2 changes: 1 addition & 1 deletion pymead/gui/bounds_values_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def handleItemChanged(self, item):
dv = self.geo_col.container()["desvar"][self.item(item.row(), 0).data(0)]

# Check if the string input is castable to a float. If not, set the float_val to None
if item.data(0).strip().replace(".", "").isnumeric():
if item.data(0).strip().replace(".", "").replace("-", "").isnumeric():
float_val = float(item.data(0).strip())
else:
float_val = None
Expand Down
12 changes: 2 additions & 10 deletions pymead/gui/parameter_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,8 @@ def __init__(self, parent, param: Param):
self.setDecimals(6)
self.setSingleStep(0.01)
self.param = param
if (isinstance(param, LengthParam) and self.param.point is None) or isinstance(param, AngleParam):
self.setMinimum(0.0)
else:
self.setMinimum(-1e9)

if isinstance(param, AngleParam):
self.setMaximum(UNITS.convert_angle_to_base(2 * np.pi, self.param.unit()))
else:
self.setMaximum(1e9)

self.setMinimum(-1e9)
self.setMaximum(1e9)
self.setValue(self.param.lower())
self.valueChanged.connect(self.onValueChanged)

Expand Down

0 comments on commit 86f641d

Please sign in to comment.