add `is_*_namespace` helper functions
closes gh-156
Let's make these not depend on the name array_api_compat. Vendoring supports renaming the module. We should be able to just compare against __name__.
Let's make these not depend on the name array_api_compat. Vendoring supports renaming the module. We should be able to just compare against name.
How should we do that? Create an array and pass it to is_*_array or is there a cheaper way?
Using just xp.__name__ seems to have problems when there are both {custom name for array_api_compat}.numpy and jax.numpy, right?
I mean the global variable __name__ will contain the name of the current module.
sorry, I don't follow - what would one of the functions look like?
Something like
def _compat_module_name():
assert __name__.endswith('.common._helpers')
return __name__.removesuffix('.common._helpers')
thanks, done
Can we add some simple tests for this and also something in the vendoring test to make sure that works?
Okay. Are there existing tests for the is_*_array functions or should I add tests for those too?
Yes, those are tested in test_common.py
One more change and this can be merged: can you add these functions to the API docs?
can you add these functions to the API docs?
done (I think)!