CLN Deprecations position args in PartialDependenceDisplay.plot #18293
Conversation
Isn't it until 0.25? |
Good catch @thomasjpfan! IIRC @glemaitre, the positional arguments are deprecated from 0.23 and will be removed in 0.25. |
|
I vote 2 I think? that seems most consistent and doesn't cost us much? |
I updated the PR to add a new keyword argument to |
The version when positional arguments will result in error. If | ||
callable, then "0.25" will be used for error message. | ||
""" | ||
if callable(version): |
amueller
Nov 20, 2020
Member
This is ugly, can't we make version keyword only to fix this, or something?
This is ugly, can't we make version keyword only to fix this, or something?
thomasjpfan
Nov 23, 2020
Author
Member
This trick is used because of how _deprecate_positional_args
's first parameter can be string:
@_deprecate_positional_args(version="0.26")
def f():
pass
or a function:
@_deprecate_positional_args
def g():
pass
The "nicer" solution would be to always provide the version, but that would be a much bigger diff.
As a side note, this trick is used in Python's lru_cache
:
This trick is used because of how _deprecate_positional_args
's first parameter can be string:
@_deprecate_positional_args(version="0.26")
def f():
pass
or a function:
@_deprecate_positional_args
def g():
pass
The "nicer" solution would be to always provide the version, but that would be a much bigger diff.
As a side note, this trick is used in Python's lru_cache
:
marked this as a blocker as we really should include this in the release as we're already behind. |
Hi @thomasjpfan sorry for doing the bad cop... Do you mind solving conflicts here, I think this PR is quite good to go, right? |
@thomasjpfan I found a solution here https://stackoverflow.com/questions/3888158/making-decorators-with-optional-arguments/24617244#24617244 that might be more intuitive and make the code a bit cleaner. The structure is the following: def _deprecate_positional_args(func=None, *, version="0.25"):
def _decorate(f):
# here goes all the previous code of _deprecate_positional_args
if func is not None:
return _decorate(func)
return _decorate |
Updated PR with @jeremiedbb's suggestion. |
Thanks @thomasjpfan. The docstring does not reflect the new implementation, I made some comments. |
In addition to @jeremiedbb suggestions, I miss a test in |
We avoided doing when working on |
OK, works with me then :) |
LGTM |
@jeremiedbb Do you want to make another pass? |
lgtm |
f82525e
into
scikit-learn:master
thanks @thomasjpfan ! |
This deprecation warning was left out, while the other
plot
methods had them.