Skip to content

Commit

Permalink
Update _base.py
Browse files Browse the repository at this point in the history
  • Loading branch information
fkiraly committed Aug 17, 2024
1 parent f960194 commit 690bb50
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion skbase/base/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,9 +1292,18 @@ def _get_fitted_params_default(self, obj=None):
fitted_params = [
attr for attr in dir(obj) if attr.endswith("_") and not attr.startswith("_")
]

def hasattr_safe(obj, attr):

Check notice

Code scanning / CodeQL

Explicit returns mixed with implicit (fall through) returns Note

Mixing implicit and explicit returns may indicate an error as implicit returns always return None.
try:
if hasattr(obj, attr):
getattr(obj, attr)
return True
except Exception:
return False

# remove the "_" at the end
fitted_param_dict = {
p[:-1]: getattr(obj, p) for p in fitted_params if hasattr(obj, p)
p[:-1]: getattr(obj, p) for p in fitted_params if hasattr_safe(obj, p)
}

return fitted_param_dict
Expand Down

0 comments on commit 690bb50

Please sign in to comment.