wjakob / nanobind

nanobind: tiny and efficient C++/Python bindings
BSD 3-Clause "New" or "Revised" License
2.29k stars 191 forks source link

Allow `ndarray_check` on objects of arbitrary modules #467

Closed njroussel closed 6 months ago

njroussel commented 6 months ago

This PR changes ndarray_check such that it returns True if one of the following conditions is met:

With this change, ndarray_check more closely matches the logic of supported imports through ndarray_import.

I've added a straightforward test which checks this new behavior on an object with a __dlpack__ attribute.

wjakob commented 6 months ago

Thanks!