Skip to content

Conversation

awni
Copy link
Member

@awni awni commented May 3, 2024

Closes #1066

This is kind of a nanobind issue but one that they have refused to fix in the past.

  • Basically a np.ndarray is implicitly convertible to a std::complex<float> so our to_array was allowing that.
  • Rather than disallowing ops with np.ndarrays instead I added it as a member in the variant.
  • That however has side effects because now mx.array gets implicitly converted to nb::ndarray because of the buffer protocol.
  • So to fix that I also had to enable array as a member of the variant.

@awni awni requested review from angeloskath and jagrit06 May 3, 2024 16:07
Copy link
Member

@angeloskath angeloskath left a comment

Choose a reason for hiding this comment

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

That's quite nice! Implicit conversion from all frameworks apparently cause nb::ndarray works with numpy, PT etc.

@awni awni merged commit 9814a2a into main May 6, 2024
@awni awni deleted the ops_with_np branch May 6, 2024 23:02
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.

[BUG] arithmetic operations with numpy arrays are not commutative
2 participants