Skip to content

Commit

Permalink
Fixed crash when par name is substring of ind. var
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesGaessler committed Nov 27, 2023
1 parent 3806d12 commit 2734cee
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kafe2/fit/_base/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,12 @@ def defaults(self, new_defaults):
def defaults_dict(self):
"""The default values for model function parameters as a dict"""
_defaults_dict = OrderedDict()
_x_name = self.x_name # Actually a list of strings that are used as independent variables
_x_name = self.x_name

# _x_name can be a list for >1 independent variables.
# Always convert to list for simpler logic.
if type(_x_name) is str:
_x_name = [_x_name]
for _par in self.signature.parameters.values():
# skip independent variable parameter
if _x_name is not None and _par.name in _x_name:
Expand Down

2 comments on commit 2734cee

@cverstege
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we rewrite the setter for self.x_name to do the conversion to list? Because right now it can be either a string or a list of strings and this could have some issues in other functions as well.

@JohannesGaessler
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think you're right.
I pushed a fixup that changes the x_name property so that it always returns a list.

Please sign in to comment.