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

Fix deprecation warning force_all_finite -> ensure_all_finite for sklearn>=1.6 #206

Merged

Conversation

icarosadero
Copy link
Contributor

@icarosadero icarosadero commented Dec 17, 2024

The current CEBRA branch raised the following deprecation message

FutureWarning: 'force_all_finite' was renamed to 'ensure_all_finite' in 1.6 and will be removed in 1.8.

See the deprecation warning in the docs

This PR adds a wrapper to cebra/integrations/sklearn/utils.py which manually adapts the argument to force_all_finite if an outdated sklearn version is used.

(edited by @stes )

@cla-bot cla-bot bot added the CLA signed label Dec 17, 2024
@stes
Copy link
Member

stes commented Dec 17, 2024

Hi @icarosadero , thanks a lot for fixing! Do you happen to know when the ensure_all_finite was introduced in scikit-learn and have a reference to the docs? As the code will require this as the new minimal version then to function, I guess?

Copy link
Member

@stes stes left a comment

Choose a reason for hiding this comment

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

ok so it seems that this is indeed an issue also for recent versions of scikit-learn:
image

If you want to take a shot at solving this, have a look at e.g. this snippet of code

def check_version(estimator):
# NOTE(stes): required as a check for the old way of specifying tags
# https://github.com/scikit-learn/scikit-learn/pull/29677#issuecomment-2334229165
from packaging import version
return version.parse(sklearn.__version__) < version.parse("1.6.dev")

You could then implement a conditional part where the version is checked, and the arg is passed based on the version of sklearn.

Copy link
Member

@stes stes left a comment

Choose a reason for hiding this comment

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

I made a suggestion which is a bit more crisp and avoids code duplication

@stes
Copy link
Member

stes commented Dec 18, 2024

could you also update the PR description with the reference to the docs, pointing that this API change happend from 1.7.x to 1.8.x?

@icarosadero icarosadero requested a review from stes December 18, 2024 11:02
@icarosadero icarosadero changed the title Fix deprecation warning force_all_finite -> ensure_all_finite Fix deprecation warning force_all_finite -> ensure_all_finite from 1.7 to 1.8 Dec 18, 2024
Copy link
Member

@stes stes left a comment

Choose a reason for hiding this comment

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

lgtm (wait with merge until #212 is merged, though)

@stes stes requested a review from MMathisLab January 21, 2025 22:27
@stes stes mentioned this pull request Jan 21, 2025
16 tasks
Copy link
Member

@stes stes left a comment

Choose a reason for hiding this comment

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

one final change, the threshold to fix the arg is 1.6, not 1.8

@stes stes changed the title Fix deprecation warning force_all_finite -> ensure_all_finite from 1.7 to 1.8 Fix deprecation warning force_all_finite -> ensure_all_finite for sklearn>=1.6 Jan 21, 2025
Copy link
Member

@stes stes left a comment

Choose a reason for hiding this comment

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

all right, final from my end

Copy link
Member

@MMathisLab MMathisLab left a comment

Choose a reason for hiding this comment

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

Lgtm; did not functionally test

@MMathisLab MMathisLab merged commit a79c2de into AdaptiveMotorControlLab:main Jan 22, 2025
13 checks passed
@icarosadero icarosadero deleted the icarosadero-patch-2 branch January 22, 2025 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants