You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "h-vetinari (via GitHub)" <gi...@apache.org> on 2025/01/11 18:14:12 UTC
[I] [Python] Compatibility with SciPy 1.15's stricter sparse code [arrow]
h-vetinari opened a new issue, #45229:
URL: https://github.com/apache/arrow/issues/45229
### Describe the enhancement requested
The test suite in https://github.com/conda-forge/arrow-cpp-feedstock/pull/1664 has a single test failure
```
=================================== FAILURES ===================================
____________ test_sparse_coo_tensor_scipy_roundtrip[f2-arrow_type8] ____________
dtype_str = 'f2', arrow_type = DataType(halffloat)
@pytest.mark.skipif(not coo_matrix, reason="requires scipy")
@pytest.mark.parametrize('dtype_str,arrow_type', tensor_type_pairs)
def test_sparse_coo_tensor_scipy_roundtrip(dtype_str, arrow_type):
dtype = np.dtype(dtype_str)
data = np.array([1, 2, 3, 4, 5, 6]).astype(dtype)
row = np.array([0, 0, 2, 3, 1, 3])
col = np.array([0, 2, 0, 4, 5, 5])
shape = (4, 6)
dim_names = ('x', 'y')
# non-canonical sparse coo matrix
> scipy_matrix = coo_matrix((data, (row, col)), shape=shape)
pyarrow/tests/test_sparse_tensor.py:408:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
scipy/sparse/_coo.py:62: in __init__
self.data = getdata(obj, copy=copy, dtype=dtype)
scipy/sparse/_sputils.py:150: in getdata
getdtype(data.dtype)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dtype = dtype('float16'), a = None, default = None
def getdtype(dtype, a=None, default=None):
"""Form a supported numpy dtype based on input arguments.
Returns a valid ``numpy.dtype`` from `dtype` if not None,
or else ``a.dtype`` if possible, or else the given `default`
if not None, or else raise a ``TypeError``.
The resulting ``dtype`` must be in ``supported_dtypes``:
bool_, int8, uint8, int16, uint16, int32, uint32,
int64, uint64, longlong, ulonglong, float32, float64,
longdouble, complex64, complex128, clongdouble
"""
if dtype is None:
try:
newdtype = a.dtype
except AttributeError as e:
if default is not None:
newdtype = np.dtype(default)
else:
raise TypeError("could not interpret data type") from e
else:
newdtype = np.dtype(dtype)
if newdtype not in supported_dtypes:
supported_dtypes_fmt = ", ".join(t.__name__ for t in supported_dtypes)
> raise ValueError(f"scipy.sparse does not support dtype {newdtype.name}. "
f"The only supported types are: {supported_dtypes_fmt}.")
E ValueError: scipy.sparse does not support dtype float16. The only supported types are: bool, int8, uint8, int16, uint16, int32, uint32, int64, uint64, longlong, ulonglong, float32, float64, longdouble, complex64, complex128, clongdouble.
scipy/sparse/_sputils.py:137: ValueError
=============================== warnings summary ===============================
```
As far as I can [tell](https://github.com/scipy/scipy/blob/v1.14.0/scipy/sparse/_sputils.py#L16), SciPy hasn't supported `float16` in sparse code for the last several years, so what happened most likely is simply that the checks got stricter in the API. If I'm wrong about that, please raise an issue in scipy.
Sidenote: compare also the [migration guide](https://scipy.github.io/devdocs/reference/sparse.migration_to_sparray.html) for getting from `scipy.sparse.*_matrix` to `scipy.sparse.*_array`, though that probably warrants a separate issue.
### Component(s)
Python
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Python] Compatibility with SciPy 1.15's stricter sparse code [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on issue #45229:
URL: https://github.com/apache/arrow/issues/45229#issuecomment-2789349160
Hey @h-vetinari , no update as of now, but I'll look into it when I get back in a week or so.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Python] Compatibility with SciPy 1.15's stricter sparse code [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on issue #45229:
URL: https://github.com/apache/arrow/issues/45229#issuecomment-3036479183
Issue resolved by pull request 46423
https://github.com/apache/arrow/pull/46423
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Python] Compatibility with SciPy 1.15's stricter sparse code [arrow]
Posted by "raulcd (via GitHub)" <gi...@apache.org>.
raulcd commented on issue #45229:
URL: https://github.com/apache/arrow/issues/45229#issuecomment-2586647601
@rok @AlenkaF @jorisvandenbossche I don't think we have any CI job that tests with scipy and this code is coming from a long time ago: https://github.com/apache/arrow/commit/cdaf9887aab8f0213ea2b1e928c0d4d998dc4461
We should exercise those tests on CI.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Python] Compatibility with SciPy 1.15's stricter sparse code [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok closed issue #45229: [Python] Compatibility with SciPy 1.15's stricter sparse code
URL: https://github.com/apache/arrow/issues/45229
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Python] Compatibility with SciPy 1.15's stricter sparse code [arrow]
Posted by "h-vetinari (via GitHub)" <gi...@apache.org>.
h-vetinari commented on issue #45229:
URL: https://github.com/apache/arrow/issues/45229#issuecomment-2788173777
@rok, any updates on this? :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Python] Compatibility with SciPy 1.15's stricter sparse code [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on issue #45229:
URL: https://github.com/apache/arrow/issues/45229#issuecomment-2593641497
Agreed @raulcd. We should also follow the migration guide as @h-vetinari suggests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Python] Compatibility with SciPy 1.15's stricter sparse code [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on issue #45229:
URL: https://github.com/apache/arrow/issues/45229#issuecomment-2875720478
Opened #46423 for the `spmatrix` -> `sparray` migration.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Python] Compatibility with SciPy 1.15's stricter sparse code [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on issue #45229:
URL: https://github.com/apache/arrow/issues/45229#issuecomment-3033118852
#46423 was merged too, closing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org