Skip to content

Conversation

@Enderdead
Copy link
Contributor

This merge request introduces the kron delegate function (#100).

All supported backends already implement the kron function. However, I wasn’t able to add support for the sparse backend because it requires all input sparse matrices to have a fill_value equal to zero (not the case in the test) - likely to avoid generating a large dense matrix.

If you’d like to discuss potential support for kron in PyData Sparse, please let me know!

Feedback is welcome.

@lucascolley lucascolley self-requested a review November 9, 2025 16:07
@lucascolley lucascolley added this to the 0.9.1 milestone Nov 9, 2025
@Enderdead
Copy link
Contributor Author

The test fails with the tests-numpy1 environment. I’m not able to reproduce this behavior on my machine (weird...).
The issue occurs when an input shape contains a zero.

I can update my delegation strategy to avoid delegating when the product of the shape elements equals zero (when using NumPy).

What do you think about this?

@lucascolley lucascolley added the enhancement New feature or request label Nov 9, 2025
@lucascolley
Copy link
Member

pixi run -e tests-numpy1 tests does reproduce the failures on my machine

@Enderdead
Copy link
Contributor Author

@lucascolley I'm a bit confused, even with your command, I still can't reproduce the issue.

~/array-api-extra$ pixi run -e tests-numpy1 tests tests/test_funcs.py::TestKron::test_kron_shape[numpy-shape_a3-shape_b3]
✨ Pixi task (tests in tests-numpy1): pytest -v tests/test_funcs.py::TestKron::test_kron_shape[numpy-shape_a3-shape_b3]: (Run tests)                                     
========================================================================== test session starts ==========================================================================
platform linux -- Python 3.10.19, pytest-7.4.4, pluggy-1.4.0 -- /home/francois/array-api-extra/.pixi/envs/tests-numpy1/bin/python3.10
cachedir: .pytest_cache
hypothesis profile 'default'
rootdir: /home/francois/array-api-extra
configfile: pyproject.toml
plugins: typeguard-2.13.3, hypothesis-6.142.3, cov-7.0.0
collected 1 item                                                                                                                                                        

tests/test_funcs.py::TestKron::test_kron_shape[numpy-shape_a3-shape_b3] PASSED

@lucascolley
Copy link
Member

what is your pixi list? For both me locally and CI, I see pytest is version 8.4.2, but your output shows pytest-7.4.4.

Maybe pixi run --locked makes a difference?

@Enderdead
Copy link
Contributor Author

Here is the information you requested:

~/array-api-extra$ pixi reinstall -e tests-numpy1
✔ The tests-numpy1 environment has been re-installed.
~/array-api-extra$ pixi list
Package           Version     Build               Size       Kind   Source
_libgcc_mutex     0.1         conda_forge         2.5 KiB    conda  https://prefix.dev/conda-forge/
_openmp_mutex     4.5         2_gnu               23.1 KiB   conda  https://prefix.dev/conda-forge/
array-api-compat  1.12.0      pyhe01879c_0        44.7 KiB   conda  https://prefix.dev/conda-forge/
array_api_extra   0.9.1.dev0                                 pypi    (editable)
bzip2             1.0.8       hda65f42_8          254.2 KiB  conda  https://prefix.dev/conda-forge/
ca-certificates   2025.10.5   hbd8a1cb_0          152.3 KiB  conda  https://prefix.dev/conda-forge/
ld_impl_linux-64  2.44        ha97dd6f_2          729.6 KiB  conda  https://prefix.dev/conda-forge/
libexpat          2.7.1       hecca717_0          73.1 KiB   conda  https://prefix.dev/conda-forge/
libffi            3.5.2       h9ec8514_0          56.5 KiB   conda  https://prefix.dev/conda-forge/
libgcc            15.2.0      h767d61c_7          803.3 KiB  conda  https://prefix.dev/conda-forge/
libgomp           15.2.0      h767d61c_7          437.4 KiB  conda  https://prefix.dev/conda-forge/
liblzma           5.8.1       hb9d3cd8_2          110.2 KiB  conda  https://prefix.dev/conda-forge/
libmpdec          4.0.0       hb9d3cd8_0          89 KiB     conda  https://prefix.dev/conda-forge/
libsqlite         3.50.4      h0c1763c_0          910.7 KiB  conda  https://prefix.dev/conda-forge/
libuuid           2.41.2      he9a06e4_0          36.3 KiB   conda  https://prefix.dev/conda-forge/
libzlib           1.3.1       hb9d3cd8_2          59.5 KiB   conda  https://prefix.dev/conda-forge/
ncurses           6.5         h2d0b736_3          870.7 KiB  conda  https://prefix.dev/conda-forge/
openssl           3.5.4       h26f9b46_0          3 MiB      conda  https://prefix.dev/conda-forge/
python            3.13.9      hc97d973_101_cp313  35.5 MiB   conda  https://prefix.dev/conda-forge/
python_abi        3.13        8_cp313             6.8 KiB    conda  https://prefix.dev/conda-forge/
readline          8.2         h8c095d6_2          275.9 KiB  conda  https://prefix.dev/conda-forge/
tk                8.6.13      noxft_hd72426e_102  3.1 MiB    conda  https://prefix.dev/conda-forge/
tzdata            2025b       h78e105d_0          120.1 KiB  conda  https://prefix.dev/conda-forge/
~/array-api-extra$ pixi run --locked -e tests-numpy1 tests tests/test_funcs.py::TestKron::test_kron_shape[numpy-shape_a3-shape_b3]
✨ Pixi task (tests in tests-numpy1): pytest -v tests/test_funcs.py::TestKron::test_kron_shape[numpy-shape_a3-shape_b3]: (Run tests)                                     
========================================================================== test session starts ==========================================================================
platform linux -- Python 3.10.19, pytest-7.4.4, pluggy-1.4.0 -- /home/francois/array-api-extra/.pixi/envs/tests-numpy1/bin/python3.10
cachedir: .pytest_cache
hypothesis profile 'default'
rootdir: /home/francois/array-api-extra
configfile: pyproject.toml
plugins: typeguard-2.13.3, hypothesis-6.142.3, cov-7.0.0
collected 1 item                                                                                                                                                        

tests/test_funcs.py::TestKron::test_kron_shape[numpy-shape_a3-shape_b3] PASSED  
~/array-api-extra$ git status
Sur la branche kron_delegate
Votre branche est à jour avec 'origin/kron_delegate'.

rien à valider, la copie de travail est propre

@lucascolley
Copy link
Member

ah sorry, I meant pixi list -e tests-numpy1

@Enderdead
Copy link
Contributor Author

This is the pixi list. I just want to mention that I have the same behaviour with two different computer using kubuntu.

pixi list -e tests-numpy1
Environment: tests-numpy1
Package            Version     Build                 Size       Kind   Source
_libgcc_mutex      0.1         conda_forge           2.5 KiB    conda  https://prefix.dev/conda-forge/
_openmp_mutex      4.5         2_gnu                 23.1 KiB   conda  https://prefix.dev/conda-forge/
array-api-compat   1.12.0      pyhe01879c_0          44.7 KiB   conda  https://prefix.dev/conda-forge/
array-api-strict   2.4.1       pyhe01879c_0          61.1 KiB   conda  https://prefix.dev/conda-forge/
array_api_extra    0.9.1.dev0                                   pypi    (editable)
attrs              25.4.0      pyh71513ae_0          58.7 KiB   conda  https://prefix.dev/conda-forge/
bzip2              1.0.8       hda65f42_8            254.2 KiB  conda  https://prefix.dev/conda-forge/
ca-certificates    2025.10.5   hbd8a1cb_0            152.3 KiB  conda  https://prefix.dev/conda-forge/
click              8.3.0       pyh707e725_0          89.5 KiB   conda  https://prefix.dev/conda-forge/
colorama           0.4.6       pyhd8ed1ab_1          26.4 KiB   conda  https://prefix.dev/conda-forge/
coverage           7.11.0      py310h3406613_0       298.7 KiB  conda  https://prefix.dev/conda-forge/
exceptiongroup     1.3.0       pyhd8ed1ab_0          20.8 KiB   conda  https://prefix.dev/conda-forge/
hypothesis         6.142.3     pyha770c72_0          370.7 KiB  conda  https://prefix.dev/conda-forge/
iniconfig          2.3.0       pyhd8ed1ab_0          13.1 KiB   conda  https://prefix.dev/conda-forge/
ld_impl_linux-64   2.44        ha97dd6f_2            729.6 KiB  conda  https://prefix.dev/conda-forge/
libblas            3.9.0       37_h4a7cf45_openblas  17.1 KiB   conda  https://prefix.dev/conda-forge/
libcblas           3.9.0       37_h0358290_openblas  17.1 KiB   conda  https://prefix.dev/conda-forge/
libexpat           2.7.1       hecca717_0            73.1 KiB   conda  https://prefix.dev/conda-forge/
libffi             3.5.2       h9ec8514_0            56.5 KiB   conda  https://prefix.dev/conda-forge/
libgcc             15.2.0      h767d61c_7            803.3 KiB  conda  https://prefix.dev/conda-forge/
libgcc-ng          15.2.0      h69a702a_7            28.6 KiB   conda  https://prefix.dev/conda-forge/
libgfortran        15.2.0      h69a702a_7            28.6 KiB   conda  https://prefix.dev/conda-forge/
libgfortran5       15.2.0      hcd61629_7            1.5 MiB    conda  https://prefix.dev/conda-forge/
libgomp            15.2.0      h767d61c_7            437.4 KiB  conda  https://prefix.dev/conda-forge/
liblapack          3.9.0       37_h47877c9_openblas  17.1 KiB   conda  https://prefix.dev/conda-forge/
liblzma            5.8.1       hb9d3cd8_2            110.2 KiB  conda  https://prefix.dev/conda-forge/
libnsl             2.0.1       hb9d3cd8_1            32.9 KiB   conda  https://prefix.dev/conda-forge/
libopenblas        0.3.30      pthreads_h94d23a6_2   5.7 MiB    conda  https://prefix.dev/conda-forge/
libsqlite          3.50.4      h0c1763c_0            910.7 KiB  conda  https://prefix.dev/conda-forge/
libstdcxx          15.2.0      h8f9b012_7            3.7 MiB    conda  https://prefix.dev/conda-forge/
libstdcxx-ng       15.2.0      h4852527_7            28.7 KiB   conda  https://prefix.dev/conda-forge/
libuuid            2.41.2      he9a06e4_0            36.3 KiB   conda  https://prefix.dev/conda-forge/
libxcrypt          4.4.36      hd590300_1            98 KiB     conda  https://prefix.dev/conda-forge/
libzlib            1.3.1       hb9d3cd8_2            59.5 KiB   conda  https://prefix.dev/conda-forge/
ncurses            6.5         h2d0b736_3            870.7 KiB  conda  https://prefix.dev/conda-forge/
numpy              1.22.0      py310h454958d_1       19.4 MiB   conda  https://prefix.dev/conda-forge/
openssl            3.5.4       h26f9b46_0            3 MiB      conda  https://prefix.dev/conda-forge/
packaging          25.0        pyh29332c3_1          61 KiB     conda  https://prefix.dev/conda-forge/
pluggy             1.6.0       pyhd8ed1ab_0          23.7 KiB   conda  https://prefix.dev/conda-forge/
pygments           2.19.2      pyhd8ed1ab_0          868.4 KiB  conda  https://prefix.dev/conda-forge/
pytest             8.4.2       pyhd8ed1ab_0          270.2 KiB  conda  https://prefix.dev/conda-forge/
pytest-cov         7.0.0       pyhcf101f3_1          28.3 KiB   conda  https://prefix.dev/conda-forge/
python             3.10.19     h3c07f61_2_cpython    24.1 MiB   conda  https://prefix.dev/conda-forge/
python_abi         3.10        8_cp310               6.8 KiB    conda  https://prefix.dev/conda-forge/
readline           8.2         h8c095d6_2            275.9 KiB  conda  https://prefix.dev/conda-forge/
setuptools         80.9.0      pyhff2d567_0          731.2 KiB  conda  https://prefix.dev/conda-forge/
sortedcontainers   2.4.0       pyhd8ed1ab_1          28 KiB     conda  https://prefix.dev/conda-forge/
tk                 8.6.13      noxft_hd72426e_102    3.1 MiB    conda  https://prefix.dev/conda-forge/
tomli              2.3.0       pyhcf101f3_0          20.5 KiB   conda  https://prefix.dev/conda-forge/
typing_extensions  4.15.0      pyhcf101f3_0          50.5 KiB   conda  https://prefix.dev/conda-forge/
tzdata             2025b       h78e105d_0            120.1 KiB  conda  https://prefix.dev/conda-forge/

@lucascolley
Copy link
Member

Do you have pytest installed globally? There is definitely a problem if pytest-7.4.4 is being used in your test runs, since your pixi list shows 8.4.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants