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

add is_*_namespace helper functions #178

Merged
merged 3 commits into from
Sep 3, 2024
Merged

Conversation

lucascolley
Copy link
Member

closes gh-156

@lucascolley lucascolley force-pushed the 156 branch 2 times, most recently from fcf6b0a to 67f3c9f Compare August 15, 2024 16:45
@asmeurer
Copy link
Member

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__.

@lucascolley
Copy link
Member Author

lucascolley commented Aug 15, 2024

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?

@asmeurer
Copy link
Member

I mean the global variable __name__ will contain the name of the current module.

@lucascolley
Copy link
Member Author

sorry, I don't follow - what would one of the functions look like?

@asmeurer
Copy link
Member

Something like

def _compat_module_name():
    assert __name__.endswith('.common._helpers')
    return __name__.removesuffix('.common._helpers')

@lucascolley
Copy link
Member Author

thanks, done

@asmeurer
Copy link
Member

Can we add some simple tests for this and also something in the vendoring test to make sure that works?

@lucascolley
Copy link
Member Author

lucascolley commented Aug 16, 2024

Okay. Are there existing tests for the is_*_array functions or should I add tests for those too?

@asmeurer
Copy link
Member

Yes, those are tested in test_common.py

@lucascolley lucascolley requested a review from asmeurer August 17, 2024 13:17
@lucascolley lucascolley force-pushed the 156 branch 2 times, most recently from 7a7f60d to bdcd14b Compare August 17, 2024 13:25
@asmeurer
Copy link
Member

One more change and this can be merged: can you add these functions to the API docs?

@lucascolley
Copy link
Member Author

can you add these functions to the API docs?

done (I think)!

@asmeurer asmeurer merged commit c656782 into data-apis:main Sep 3, 2024
43 checks passed
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.

Add is_numpy_namespace, etc. helper functions
3 participants