-
Notifications
You must be signed in to change notification settings - Fork 53
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
MNT support older cython types' reduce #453
Conversation
@TamaraAtanasoska @BenjaminBossan this actually fixes the cython issues. WDYT? |
I'm loving my |
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.
Thanks for this update, I just added a small comment.
@@ -214,8 +220,24 @@ def __init__( | |||
|
|||
|
|||
def loss_get_state(obj: Any, save_context: SaveContext) -> dict[str, Any]: | |||
state = reduce_get_state(obj, save_context) | |||
state["__loader__"] = "LossNode" | |||
reduce = obj.__reduce__() |
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.
Maybe another name as reduce
used to be builtin (and there is still functools.reduce
)?
Also: If the Cython version is too low, would the obj.__reduce__()
fail? If this could realistically happen to users, the error could be intercepted and reraised with the message that users should update Cython to version x.y.z.
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.
For now we are running this code for known objects, and since Cython is a build dependency and the installed cython doesn't matter, and that we use modern cython in sklearn build, we're fine.
But if we start supporting arbitrary objects via reduce for cython, then this would be an issue.
Cython at some point automatically started to add
__reduce__
to objects, which is not too bad.This also adds tests for sklearn versions 1.4 and 1.3