From b3c39d81d505a3a85d70e281be1628932724d693 Mon Sep 17 00:00:00 2001 From: Debian Python Team Date: Wed, 25 Jan 2023 14:32:10 +0000 Subject: [PATCH] fix_numpy1.24_PR17035 =================================================================== Gbp-Pq: Name fix_numpy1.24_PR17035.patch --- scipy/sparse/_sputils.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scipy/sparse/_sputils.py b/scipy/sparse/_sputils.py index add718f2..b7fb0729 100644 --- a/scipy/sparse/_sputils.py +++ b/scipy/sparse/_sputils.py @@ -11,7 +11,8 @@ __all__ = ['upcast', 'getdtype', 'getdata', 'isscalarlike', 'isintlike', 'isshape', 'issequence', 'isdense', 'ismatrix', 'get_sum_dtype'] supported_dtypes = [np.bool_, np.byte, np.ubyte, np.short, np.ushort, np.intc, - np.uintc, np.int_, np.uint, np.longlong, np.ulonglong, np.single, np.double, + np.uintc, np.int_, np.uint, np.longlong, np.ulonglong, + np.single, np.double, np.longdouble, np.csingle, np.cdouble, np.clongdouble] _upcast_memo = {} @@ -89,7 +90,19 @@ def downcast_intp_index(arr): def to_native(A): - return np.asarray(A, dtype=A.dtype.newbyteorder('native')) + """ + Ensure that the data type of the NumPy array `A` has native byte order. + + `A` must be a NumPy array. If the data type of `A` does not have native + byte order, a copy of `A` with a native byte order is returned. Otherwise + `A` is returned. + """ + dt = A.dtype + if dt.isnative: + # Don't call `asarray()` if A is already native, to avoid unnecessarily + # creating a view of the input array. + return A + return np.asarray(A, dtype=dt.newbyteorder('native')) def getdtype(dtype, a=None, default=None): -- 2.30.2