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
Buffer dtype mismatch, expected 'ITYPE_t' but got 'long' #18716
Comments
Could you upload your matrix as a .npz file? Otherwise this will not be possible to debug. |
I don't think uploading the matrix will be necessary here, actually. Instead, could you print |
I suspect this is a fallout of #18509 (or something related); a simple repro is
which prints
(as above) with scipy 1.11.1. |
Thanks for the reproducer, @anntzer ! This definitely looks like fallout from #18509, similar to the recently-fixed #18603. Looking at the Cython code in question, we may be able to fix this by using a fused index type in _traversal.pyx, as in scipy/scipy/sparse/csgraph/_traversal.pyx Lines 647 to 650 in ddee711
There's a precedent for this in other csgraph Cython code: scipy/scipy/sparse/csgraph/_reordering.pyx Lines 102 to 103 in 3c89445
The other option is to do what we did in #18644 and downcast the index arrays before calling the Cython code, but I'd prefer to try the fused type first. |
Closes gh-18716 Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
) Closes scipygh-18716 Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
I am trying to get connected components in an adjacency matrix which is quite big but sparse. However when I run the code, I get this error:
ValueError: Buffer dtype mismatch, expected 'ITYPE_t' but got 'long'
Exception ignored in: 'scipy.sparse.csgraph._traversal._connected_components_undirected'
ValueError: Buffer dtype mismatch, expected 'ITYPE_t' but got 'long'
When I run the code for a smaller matrix everything works fine.
Reproducing Code Example
Error message
SciPy/NumPy/Python version and system information
The text was updated successfully, but these errors were encountered: