Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] safer get_fitted_params default functionality to avoid exception on getattr #353

Merged
merged 3 commits into from
Aug 23, 2024

Conversation

fkiraly
Copy link
Contributor

@fkiraly fkiraly commented Aug 17, 2024

This PR makes the get_fitted_params core functionality and defaults safer against exceptions on getattr.

In rare cases, getattr can cause an exception, namely if a property is being accessed in a way that generates an exception.

Examples are some fitted parameter arguments in sklearn that are decorated as property in newer versions, e.g., RandomForestRegressor.estimator_ in unfitted state.

In most use cases, there will be no change in behaviour; in the described case where an exception would be raised, this is now caught and suppressed, and the corresponding parameter is considered as not present.

Changes occur only in cases that would have previously raised genuine exceptions, so no working code is affected, and no deprecation is necessary despite this being a change to a core interface element.

@fkiraly fkiraly added the enhancement Adding new functionality label Aug 17, 2024
skbase/base/_base.py Fixed Show fixed Hide fixed
@fkiraly fkiraly merged commit 2d6dcfe into main Aug 23, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant