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

Make reflected binary method transparent #40

Merged
merged 2 commits into from
Aug 10, 2023
Merged

Conversation

saulshanabrook
Copy link
Member

This PR makes reflected binary methods (i.e. __radd__) transparent, so that they map directly to the non reflected versions.

This differs from the original implementation in #35 (which kept them as separate extensions).

That approach had a few flaws:

  • The str representation of binary and non binary operators looked the same, which made them hard to debug. This could have been worked around by non pretty printing the reflective operators (i.e. keeping them as methods instead of operators).
  • It was hard to define replacements for reflective operators, since they really only were activated on converted/non supported types.

This new method is a bit more magic, but should work for any expressions as long as their mathematical operators behave as one would expect for the reversed versions.

In this PR the array API notebook can now be run as well!

This PR makes reflected binary methods (i.e. `__radd__`) transparent,
so that they map directly to the non reflected versions.

This differs from the original implementation in #35 (which kept them as separate extensions).

That approach had a few flaws:

* The `str` representation of binary and non binary operators looked the same, which made them hard to debug. This could have been worked around by non pretty printing the reflective operators (i.e. keeping them as methods instead of operators).
* It was hard to define replacements for reflective operators, since they really only were activated on converted/non supported types.

This new method is a bit more magic, but should work for any expressions as long as their mathematical operators behave as one would
expect for the reversed versions.
@saulshanabrook saulshanabrook merged commit 0fb85dc into main Aug 10, 2023
9 checks passed
@saulshanabrook saulshanabrook deleted the next-sklearn branch August 10, 2023 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant