Skip to content

🧱 static integration testing #35

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

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

jorenham
Copy link
Member

@jorenham jorenham commented Jul 2, 2025

Currently limited and numpy and only uses mypy. I plan to add (based)pyright in a follow-up.

Closes ##25 I guess

@jorenham jorenham added the 🧪+ failing test Add a failing test. label Jul 2, 2025
@jorenham jorenham added this to the v2021-12-0.0 milestone Jul 2, 2025
@jorenham jorenham requested a review from nstarman July 2, 2025 12:30
@jorenham jorenham marked this pull request as draft July 2, 2025 12:30
@jorenham
Copy link
Member Author

jorenham commented Jul 2, 2025

So numpy isn't compatible with our HasArrayNamespace protocol, because numpy uses string literals, instead of str in the input position (which is contravariant).

@jorenham jorenham changed the title 🧱 statiic integration testing 🧱 static integration testing Jul 2, 2025
Copy link
Collaborator

@nstarman nstarman left a comment

Choose a reason for hiding this comment

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

Overall looks great. Couple Q's.

@nstarman
Copy link
Collaborator

nstarman commented Jul 2, 2025

What string literals does it expect? Limited to the list of compatible versions?

@jorenham
Copy link
Member Author

jorenham commented Jul 2, 2025

What string literals does it expect? Limited to the list of compatible versions?

In numpy 2.3.1 it [looks like this]:(https://github.com/numpy/numpy/blob/4d833e5df760c382f24ee3eb643dc20c3da4a5a1/numpy/__init__.pyi#L1684)

_ArrayAPIVersion: TypeAlias = L["2021.12", "2022.12", "2023.12", "2024.12"]

# --snip--

def __array_namespace__(self, /, *, api_version: _ArrayAPIVersion | None = None) -> ModuleType: ...

in 2.0.2 it looks like this:

def __array_namespace__(self, *, api_version: str | None = ...) -> Any: ...

and <2.0.0 there was no __array_namespace__

@jorenham
Copy link
Member Author

jorenham commented Jul 2, 2025

Huh, why is mypy using the stubs from numpy 2.3.1 when numpy 1.25.0 is installed?
https://github.com/data-apis/array-api-typing/actions/runs/16028175155/job/45221469410?pr=35

@jorenham
Copy link
Member Author

jorenham commented Jul 2, 2025

So mypy apparently completely ignores build isolation...

The workaround is to use uv pip install, instead of uv run --with, which layers the dependencies. It's disgustingly ugly, but at least the tests are failing for the right reasons now...

@jorenham
Copy link
Member Author

jorenham commented Jul 2, 2025

Ok, now the question remains: What to do with numpy<2? Ignore it (for now), script our way around it by using array-api-compat if numpy<2, or split it up into two separate integration tests?

@lucascolley
Copy link
Member

My feeling is that we are going to end up using array-api-compat anyway, no? I guess not for older versions of the standard, but as the standard is developed.

@jorenham
Copy link
Member Author

jorenham commented Jul 2, 2025

My feeling is that we are going to end up using array-api-compat anyway, no? I guess not for older versions of the standard, but as the standard is developed.

for the purposes of integration testing it might be a good idea to rely on it as little as we can

@jorenham
Copy link
Member Author

jorenham commented Jul 2, 2025

My feeling is that we are going to end up using array-api-compat anyway, no? I guess not for older versions of the standard, but as the standard is developed.

Testing both is also an option 🤔

@lucascolley
Copy link
Member

may as well ignore it for now if we can pass without it, and see what happens down the line

@jorenham

This comment was marked as outdated.

@jorenham
Copy link
Member Author

jorenham commented Jul 2, 2025

Nevermind, I managed to get this working on numpy<2 by using np.array_api there. It required a little bit of black voodoo magic in the gha workflow, and it's not ideal in terms of IDE support, but it's the cleanest way I could think of.

@jorenham jorenham marked this pull request as ready for review July 2, 2025 18:23
Copy link
Collaborator

@nstarman nstarman left a comment

Choose a reason for hiding this comment

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

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧪+ failing test Add a failing test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants