public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/scipy] rawhide: Fix NumPy 2.5 deprecation of setting .shape on arrays
Date: Wed, 22 Jul 2026 12:39:49 GMT	[thread overview]
Message-ID: <178472398954.1.8252846950916814911.rpms-scipy-bfb5c84187a3@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/scipy
            Branch : rawhide
            Commit : bfb5c84187a3bcd5f778ff0bf3b87424bdd29a60
            Author : Miro Hrončok <miro@hroncok.cz>
            Date   : 2026-07-22T14:10:14+02:00
            Stats  : +204/-0 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/scipy/c/bfb5c84187a3bcd5f778ff0bf3b87424bdd29a60?branch=rawhide

            Log:
            Fix NumPy 2.5 deprecation of setting .shape on arrays

This fixes a test failure:

    DeprecationWarning: Setting the shape on a NumPy array has been deprecated in NumPy 2.5

---
diff --git a/4bdac888ec.patch b/4bdac888ec.patch
new file mode 100644
index 0000000..f4b709d
--- /dev/null
+++ b/4bdac888ec.patch
@@ -0,0 +1,156 @@
+From 4bdac888ec4104db9256012ff784a62693b106a1 Mon Sep 17 00:00:00 2001
+From: Pieter Eendebak <pieter.eendebak@gmail.com>
+Date: Fri, 29 Aug 2025 16:39:35 +0200
+Subject: [PATCH] Use reshape instead of setting the shape attribute
+
+---
+ scipy/datasets/_fetchers.py |  3 +--
+ scipy/io/_netcdf.py         |  4 ++--
+ scipy/odr/_models.py        | 28 ++++++++++------------------
+ scipy/stats/_stats_py.py    |  2 +-
+ 4 files changed, 14 insertions(+), 23 deletions(-)
+
+diff --git a/scipy/datasets/_fetchers.py b/scipy/datasets/_fetchers.py
+index 190621e37bec..f6389a0ca5da 100644
+--- a/scipy/datasets/_fetchers.py
++++ b/scipy/datasets/_fetchers.py
+@@ -222,8 +222,7 @@ def face(gray=False):
+     with open(fname, 'rb') as f:
+         rawdata = f.read()
+     face_data = bz2.decompress(rawdata)
+-    face = frombuffer(face_data, dtype='uint8')
+-    face.shape = (768, 1024, 3)
++    face = frombuffer(face_data, dtype='uint8').reshape((768, 1024, 3))
+     if gray is True:
+         face = (0.21 * face[:, :, 0] + 0.71 * face[:, :, 1] +
+                 0.07 * face[:, :, 2]).astype('uint8')
+diff --git a/scipy/io/_netcdf.py b/scipy/io/_netcdf.py
+index 14499ccb769f..0aef5d49b11a 100644
+--- a/scipy/io/_netcdf.py
++++ b/scipy/io/_netcdf.py
+@@ -696,13 +696,13 @@ def _read_var_array(self):
+                 a_size = reduce(mul, shape, 1) * size
+                 if self.use_mmap:
+                     data = self._mm_buf[begin_:begin_+a_size].view(dtype=dtype_)
+-                    data.shape = shape
++                    data = data.reshape(shape)
+                 else:
+                     pos = self.fp.tell()
+                     self.fp.seek(begin_)
+                     data = frombuffer(self.fp.read(a_size), dtype=dtype_
+                                       ).copy()
+-                    data.shape = shape
++                    data = data.reshape(shape)
+                     self.fp.seek(pos)
+ 
+             # Add variable.
+diff --git a/scipy/odr/_models.py b/scipy/odr/_models.py
+index e0a8d2275dcc..c4ca5b6f442e 100644
+--- a/scipy/odr/_models.py
++++ b/scipy/odr/_models.py
+@@ -9,7 +9,7 @@
+ 
+ def _lin_fcn(B, x):
+     a, b = B[0], B[1:]
+-    b.shape = (b.shape[0], 1)
++    b = b.reshape((b.shape[0], 1))
+ 
+     return a + (x*b).sum(axis=0)
+ 
+@@ -17,15 +17,13 @@ def _lin_fcn(B, x):
+ def _lin_fjb(B, x):
+     a = np.ones(x.shape[-1], float)
+     res = np.concatenate((a, x.ravel()))
+-    res.shape = (B.shape[-1], x.shape[-1])
+-    return res
++    return res.reshape((B.shape[-1], x.shape[-1]))
+ 
+ 
+ def _lin_fjd(B, x):
+     b = B[1:]
+     b = np.repeat(b, (x.shape[-1],)*b.shape[-1], axis=0)
+-    b.shape = x.shape
+-    return b
++    return b.reshape(x.shape)
+ 
+ 
+ def _lin_est(data):
+@@ -43,7 +41,7 @@ def _lin_est(data):
+ 
+ def _poly_fcn(B, x, powers):
+     a, b = B[0], B[1:]
+-    b.shape = (b.shape[0], 1)
++    b = b.reshape((b.shape[0], 1))
+ 
+     return a + np.sum(b * np.power(x, powers), axis=0)
+ 
+@@ -51,13 +49,12 @@ def _poly_fcn(B, x, powers):
+ def _poly_fjacb(B, x, powers):
+     res = np.concatenate((np.ones(x.shape[-1], float),
+                           np.power(x, powers).flat))
+-    res.shape = (B.shape[-1], x.shape[-1])
+-    return res
++    return res.reshape((B.shape[-1], x.shape[-1]))
+ 
+ 
+ def _poly_fjacd(B, x, powers):
+     b = B[1:]
+-    b.shape = (b.shape[0], 1)
++    b = b.reshape((b.shape[0], 1))
+ 
+     b = b * powers
+ 
+@@ -74,8 +71,7 @@ def _exp_fjd(B, x):
+ 
+ def _exp_fjb(B, x):
+     res = np.concatenate((np.ones(x.shape[-1], float), x * np.exp(B[1] * x)))
+-    res.shape = (2, x.shape[-1])
+-    return res
++    return res.reshape((2, x.shape[-1]))
+ 
+ 
+ def _exp_est(data):
+@@ -163,7 +159,7 @@ def polynomial(order):
+         # Scalar.
+         powers = np.arange(1, powers + 1)
+ 
+-    powers.shape = (len(powers), 1)
++    powers = powers.reshape((len(powers), 1))
+     len_beta = len(powers) + 1
+ 
+     def _poly_est(data, len_beta=len_beta):
+@@ -221,9 +217,7 @@ def _unilin_fjd(B, x):
+ 
+ def _unilin_fjb(B, x):
+     _ret = np.concatenate((x, np.ones(x.shape, float)))
+-    _ret.shape = (2,) + x.shape
+-
+-    return _ret
++    return _ret.reshape((2,) + x.shape)
+ 
+ 
+ def _unilin_est(data):
+@@ -240,9 +234,7 @@ def _quad_fjd(B, x):
+ 
+ def _quad_fjb(B, x):
+     _ret = np.concatenate((x*x, x, np.ones(x.shape, float)))
+-    _ret.shape = (3,) + x.shape
+-
+-    return _ret
++    return _ret.reshape((3,) + x.shape)
+ 
+ 
+ def _quad_est(data):
+diff --git a/scipy/stats/_stats_py.py b/scipy/stats/_stats_py.py
+index 4762a20e83b1..f76273c65d4e 100644
+--- a/scipy/stats/_stats_py.py
++++ b/scipy/stats/_stats_py.py
+@@ -2073,7 +2073,7 @@ def _compute_qth_percentile(sorted_, per, interpolation_method, axis):
+         weights = array([(j - idx), (idx - i)], float)
+         wshape = [1] * sorted_.ndim
+         wshape[axis] = 2
+-        weights.shape = wshape
++        weights = weights.reshape(wshape)
+         sumval = weights.sum()
+ 
+     # Use np.add.reduce (== np.sum but a little faster) to coerce data type

diff --git a/e90159476a.patch b/e90159476a.patch
new file mode 100644
index 0000000..14ae8c1
--- /dev/null
+++ b/e90159476a.patch
@@ -0,0 +1,44 @@
+From e90159476a2032b73154bdc727629f1cdbdb1064 Mon Sep 17 00:00:00 2001
+From: Pieter Eendebak <pieter.eendebak@gmail.com>
+Date: Fri, 29 Aug 2025 19:22:51 +0200
+Subject: [PATCH] last replacements
+
+---
+ scipy/io/_netcdf.py          | 4 ++--
+ scipy/stats/_multivariate.py | 3 ++-
+ 2 files changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/scipy/io/_netcdf.py b/scipy/io/_netcdf.py
+index 0aef5d49b11a..d810c583056c 100644
+--- a/scipy/io/_netcdf.py
++++ b/scipy/io/_netcdf.py
+@@ -720,13 +720,13 @@ def _read_var_array(self):
+             if self.use_mmap:
+                 buf = self._mm_buf[begin:begin+self._recs*self._recsize]
+                 rec_array = buf.view(dtype=dtypes)
+-                rec_array.shape = (self._recs,)
++                rec_array = rec_array.reshape((self._recs,))
+             else:
+                 pos = self.fp.tell()
+                 self.fp.seek(begin)
+                 rec_array = frombuffer(self.fp.read(self._recs*self._recsize),
+                                        dtype=dtypes).copy()
+-                rec_array.shape = (self._recs,)
++                rec_array = rec_array.reshape((self._recs,))
+                 self.fp.seek(pos)
+ 
+             for var in rec_vars:
+diff --git a/scipy/stats/_multivariate.py b/scipy/stats/_multivariate.py
+index d36e9ffa4c8f..ee97fe88a2d8 100644
+--- a/scipy/stats/_multivariate.py
++++ b/scipy/stats/_multivariate.py
+@@ -3483,7 +3483,8 @@ def entropy(self, n, p):
+ 
+         n = n[..., np.newaxis]
+         new_axes_needed = max(p.ndim, n.ndim) - x.ndim + 1
+-        x.shape += (1,)*new_axes_needed
++        new_shape = x.shape + (1,)*new_axes_needed
++        x = x.reshape(new_shape)
+ 
+         term2 = np.sum(binom.pmf(x, n, p)*gammaln(x+1),
+                        axis=(-1, -1-new_axes_needed))

diff --git a/scipy.spec b/scipy.spec
index 3f16103..8ab4afc 100644
--- a/scipy.spec
+++ b/scipy.spec
@@ -70,6 +70,10 @@ License:    BSD-3-Clause AND BSD-2-Clause AND MIT AND BSL-1.0 AND Boehm-GC AND Q
 Url:        https://scipy.org/
 Source0:    https://github.com/scipy/scipy/releases/download/v%{version}/scipy-%{version}.tar.gz
 
+# Fix NumPy 2.5 deprecation of setting .shape on arrays
+Patch:      https://github.com/scipy/scipy/commit/4bdac888ec.patch
+Patch:      https://github.com/scipy/scipy/commit/e90159476a.patch
+
 BuildRequires: %{blaslib}-devel
 BuildRequires: gcc-gfortran, gcc-c++
 

                 reply	other threads:[~2026-07-22 12:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178472398954.1.8252846950916814911.rpms-scipy-bfb5c84187a3@fedoraproject.org \
    --to=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox