Skip to content

Array API 2025.12 support - #943

Merged
hameerabbasi merged 12 commits into
pydata:mainfrom
hameerabbasi:array-api-2025.12
Jul 1, 2026
Merged

Array API 2025.12 support#943
hameerabbasi merged 12 commits into
pydata:mainfrom
hameerabbasi:array-api-2025.12

Conversation

@hameerabbasi

Copy link
Copy Markdown
Collaborator

What type of PR is this? (check all applicable)

  • 💾 Refactor
  • 🪄 Feature
  • 🐞 Bug Fix
  • 🔧 Optimization
  • 📚 Documentation
  • 🧪 Test
  • 🛠️ Other

Related issues

Checklist

  • Code follows style guide
  • Tests added
  • Documented the changes

@hameerabbasi
hameerabbasi requested a review from prady0t June 18, 2026 15:26
@hameerabbasi

Copy link
Copy Markdown
Collaborator Author

@prady0t __ifloordiv__ fails for some weird reason I can't figure out; all other tests (including elemwise) succeed. Maybe an issue with the test suite or a latent bug?

@codspeed-hq

codspeed-hq Bot commented Jun 18, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 11.63%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 338 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
test_index_fancy[side=100-rank=1-format='coo'] 1.1 ms 1.4 ms -19.8%
test_index_slice[side=100-rank=2-format='gcxs'] 3.5 ms 2.2 ms +55.37%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing hameerabbasi:array-api-2025.12 (1bd2d5a) with main (c4ed43f)

Open in CodSpeed

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
@prady0t

prady0t commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

I think the hypothesis issue has now been resolved. After a lot of effort, I found out that the asarray implementation in sparse does not take copy into account. See the latest commit I pushed.

Also see this example:

import numpy as np
from sparse.numba_backend import COO, asarray

x = COO.from_numpy(np.array(6.0))
y = asarray(x, copy=True)
a = asarray(x, copy=False)
z = np.asarray(x.todense(), copy=True)
print(id(x), id(y), id(z), id(a))
print(x is a)
print(x is y)
print(x is z)

The output is:

5727776080 5727776080 5770313616 5727776080
True
True
False

Which means x, y, and a are the same object, and it does not affect the object if set to True or False, whereas copy should produce different objects, just like z

After this commit, the output is:

6072479056 6072479376 6073926064 6072479056
True
False
False

Which is the correct behaviour.

@hameerabbasi

Copy link
Copy Markdown
Collaborator Author

Well done tracking that down! Can we add a test to ensure that asarray with copy=True copies for all formats?

@prady0t

prady0t commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Can we add a test to ensure that asarray with copy=True copies for all formats?

Sure. In this PR itself?

@hameerabbasi

Copy link
Copy Markdown
Collaborator Author

Sure. In this PR itself?

That'd be nice.

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
@prady0t

prady0t commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

DOK had no copy(); added it in the latest commit(inspired by GCXS copy).

prady0t
prady0t previously approved these changes Jul 1, 2026
@hameerabbasi

Copy link
Copy Markdown
Collaborator Author

Still need to remove some xfails. I'll do that later today.

@hameerabbasi
hameerabbasi marked this pull request as ready for review July 1, 2026 14:00
@hameerabbasi
hameerabbasi merged commit 39331ec into pydata:main Jul 1, 2026
12 of 14 checks passed
@hameerabbasi
hameerabbasi deleted the array-api-2025.12 branch July 1, 2026 14:01
@lucascolley

Copy link
Copy Markdown
Collaborator

I found out that the asarray implementation in sparse does not take copy into account.

I wonder why we didn't catch this earlier (and more easily) via the array-api-tests suite? Is there something we should add over there?

@hameerabbasi

Copy link
Copy Markdown
Collaborator Author

I wonder why we didn't catch this earlier (and more easily) via the array-api-tests suite? Is there something we should add over there?

You probably do; but by default the arrays are also immutable (don't implement setitem) in PyData/Sparse; which is why the test probably got skipped.

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.

array API: add broadcast_shapes

3 participants