From: Debian Python Team Date: Thu, 19 Jan 2023 13:54:51 +0000 (+0000) Subject: fix_numpy1.24_PR17035 X-Git-Tag: archive/raspbian/1.8.1-21+rpi1^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=28f19ca16afefdf2cabfb52c5bc1c8985f7c628b;p=scipy.git fix_numpy1.24_PR17035 =================================================================== Gbp-Pq: Name fix_numpy1.24_PR17035.patch --- 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):