-
Notifications
You must be signed in to change notification settings - Fork 14
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
[BUG] fix faulty BaseObject.__eq__
and deep_equals
if an attribute or nested structure contains np.nan
#111
Conversation
@RNKuhns, why are unrelated tests (for package structure lookup) failing here? |
I get it, you used |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #111 +/- ##
==========================================
+ Coverage 78.05% 78.07% +0.02%
==========================================
Files 23 23
Lines 1877 1884 +7
==========================================
+ Hits 1465 1471 +6
- Misses 412 413 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fkiraly the all_extras optional dependencies in pyproject.toml
needs to be updated to include numpy
.
This doesn't fail in our CI workflow, because that is installing all test dependencies and numpy
is already a test dependency. But we want to give users the easy of installing the extras.
@fkiraly the other thing I didn't mention explicitly in my review is that we need to determine how you want this fix published. If having it available by early-February in However, if you want a patch (bug fix) release, we want to keep the changes there to minimum (bug fixes only) if possible (which impacts decision on merging other branches). Let me know what you are thinking on the timing. Moving forward, it might make sense to open a release branch and merge PRs for a release into that branch. That way it is easy to do quick bug fix releases, since we know main will have limited changes. |
Is that really an omission or problem of this PR? |
I just overrode |
@fkiraly it appears they did. But the gist of it was that we should make a PR that expands the mock_package in the test module, so that it covers more cases needed for tests (non-public functions, modules to make sure retrieval can exclude them; non-public modules to make sure we can exclude those and some sub-module nesting, etc). I'll try to do that this week. |
just to clarify, do you want the |
I'm fine with it being separate PR. Can you open that? |
…e or nested structure contains `float` (#4109) This fixes `deep_equals` logic and reverse dependency `BaseObject.__eq__` for the case that parameters or nested objects contained an `float`. Incorrectly, any two floats were considered equal. This is a consequence of erroneous logic to cover the case of `np.nan`. For more context, also see sktime/skbase#111 Tests were also added to ensure that the `float` and `np.nan` case are both covered correctly.
Sure, opened a PR with numpy here: #121 |
@fkiraly wanted to verify this is good to go (with all updated logic from sktime) before merging. |
yes, good to go from my side. |
(you still haven't approved? is there sth I should change?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Adding of numpy soft dependency is in #121.
BaseObject.__eq__
anddeep_equals
return the wrong answer if somewhere in the structure annp.nan
occurs. This is becausenp.nan != np.nan
by default.For
BaseObject
-s, this can lead to failures of equality whenever somehwere in the nested structure (of parameters) annp.nan
is contained.This happens to be the case for tuner default parameter settings in
sktime
, which makes the refactor fail for those specific estimators, see here: sktime/sktime#3151 (comment)This bugfix handles the case
np.nan
indeep_equals
, which fixes it in its reverse dependencyBaseObject.__eq__
.Curiously, the
np.nan
case was handled insktime
, but incorrectly. The check insktime
incorrectly considers any two floats as being equal (rather than just two instances ofnp.nan
which happens to be of typefloat
).In another failure, the handling of
np.nan
was removed (instead of being fixed) whendeep_equals
was ported toskbase
.Together, this explains the presence of the bug in
skbase
, the failure of tests in the refactor PR onsktime
tuners, and the absence of test failures on themain
branch ofsktime
.I've also added more test cases for
deep_equals
to cover the failures aroundnp.nan
which are being fixed here.