1
0

Accepting request 1189472 from devel:languages:python:numeric

- Remove numpy upper bound.
- Add patch support-numpy-2.patch:
  * Use np.asarray() to support NumPy 2 as well.

OBS-URL: https://build.opensuse.org/request/show/1189472
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-nibabel?expand=0&rev=13
This commit is contained in:
Dominique Leuenberger 2024-07-25 13:39:34 +00:00 committed by Git OBS Bridge
commit c5e3b1d134
3 changed files with 47 additions and 2 deletions

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Jul 25 02:05:50 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- Remove numpy upper bound.
- Add patch support-numpy-2.patch:
* Use np.asarray() to support NumPy 2 as well.
-------------------------------------------------------------------
Mon Jul 22 05:51:49 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>

View File

@ -27,15 +27,17 @@ URL: https://nipy.org/nibabel
Source: https://files.pythonhosted.org/packages/source/n/nibabel/nibabel-%{version}.tar.gz
# PATCH-FIX-UPSTREAM gh#nipy/nibabel#1325
Patch0: support-pytest-8.patch
# PATCH-FIX-UPSTREAM gh#nipy/nibabel#1304
Patch1: support-numpy-2.patch
BuildRequires: %{python_module base >= 3.8}
BuildRequires: %{python_module hatch-vcs}
BuildRequires: %{python_module hatchling}
BuildRequires: %{python_module pip}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-numpy >= 1.20
Requires: python-packaging => 17
Requires: (python-importlib-resources >= 1.3 if python-base < 3.9)
Requires: (python-numpy >= 1.20 with python-numpy < 2)
Requires(post): update-alternatives
Requires(postun): update-alternatives
Recommends: python-Pillow
@ -47,7 +49,7 @@ BuildArch: noarch
BuildRequires: %{python_module Pillow}
BuildRequires: %{python_module h5py}
BuildRequires: %{python_module importlib-resources >= 1.3 if %python-base < 3.9}
BuildRequires: %{python_module numpy >= 1.20 with %python-numpy < 2}
BuildRequires: %{python_module numpy >= 1.20}
BuildRequires: %{python_module packaging >= 17}
BuildRequires: %{python_module pydicom >= 1}
BuildRequires: %{python_module pytest-doctestplus}

36
support-numpy-2.patch Normal file
View File

@ -0,0 +1,36 @@
From 2bad8cce331976af3e8b42cecaed76bb075ee8b3 Mon Sep 17 00:00:00 2001
From: Chris Markiewicz <effigies@gmail.com>
Date: Tue, 5 Mar 2024 08:16:05 -0500
Subject: [PATCH] FIX: Use np.asarray instead of np.array(..., copy=False)
---
nibabel/affines.py | 2 +-
nibabel/casting.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/nibabel/affines.py b/nibabel/affines.py
index 05fdd7bb5..1478fd2dc 100644
--- a/nibabel/affines.py
+++ b/nibabel/affines.py
@@ -365,7 +365,7 @@ def rescale_affine(affine, shape, zooms, new_shape=None):
A new affine transform with the specified voxel sizes
"""
- shape = np.array(shape, copy=False)
+ shape = np.asarray(shape)
new_shape = np.array(new_shape if new_shape is not None else shape)
s = voxel_sizes(affine)
diff --git a/nibabel/casting.py b/nibabel/casting.py
index f3e04f30f..09015135f 100644
--- a/nibabel/casting.py
+++ b/nibabel/casting.py
@@ -611,7 +611,7 @@ def int_abs(arr):
>>> int_abs(np.array([-128, 127], dtype=np.float32))
array([128., 127.], dtype=float32)
"""
- arr = np.array(arr, copy=False)
+ arr = np.asarray(arr)
dt = arr.dtype
if dt.kind == 'u':
return arr