forked from pool/python-sherpa
Accepting request 1109765 from devel:languages:python:numeric
OBS-URL: https://build.opensuse.org/request/show/1109765 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-sherpa?expand=0&rev=17
This commit is contained in:
commit
66ebaa0d74
96
numpy125-CI.patch
Normal file
96
numpy125-CI.patch
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
From 2aea86a2a596323e9c8e41275acbffa1e9a609a0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Doug Burke <dburke@cfa.harvard.edu>
|
||||||
|
Date: Mon, 17 Jul 2023 11:33:29 -0400
|
||||||
|
Subject: [PATCH 1/2] Silence test warnings if pytest-doctestplus is not
|
||||||
|
installed
|
||||||
|
|
||||||
|
I originally tried adding the warnings to sherpa/conftest.py but
|
||||||
|
this is happening in pytest itself, so I've taken advantage of
|
||||||
|
the general filter-warnings capability to hide thse messages.
|
||||||
|
|
||||||
|
Before this change, running pytest without pytest-doctestplus would
|
||||||
|
result in messages like
|
||||||
|
|
||||||
|
==================================================== warnings summary =====================================================
|
||||||
|
../../../lagado2.real/local/anaconda/envs/sherpa-main/lib/python3.11/site-packages/_pytest/config/__init__.py:1373
|
||||||
|
/lagado2.real/local/anaconda/envs/sherpa-main/lib/python3.11/site-packages/_pytest/config/__init__.py:1373: PytestConfigWarning: Unknown config option: doctest_norecursedirs
|
||||||
|
|
||||||
|
self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
|
||||||
|
|
||||||
|
../../../lagado2.real/local/anaconda/envs/sherpa-main/lib/python3.11/site-packages/_pytest/config/__init__.py:1373
|
||||||
|
/lagado2.real/local/anaconda/envs/sherpa-main/lib/python3.11/site-packages/_pytest/config/__init__.py:1373: PytestConfigWarning: Unknown config option: doctest_plus
|
||||||
|
|
||||||
|
self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
|
||||||
|
|
||||||
|
../../../lagado2.real/local/anaconda/envs/sherpa-main/lib/python3.11/site-packages/_pytest/config/__init__.py:1373
|
||||||
|
/lagado2.real/local/anaconda/envs/sherpa-main/lib/python3.11/site-packages/_pytest/config/__init__.py:1373: PytestConfigWarning: Unknown config option: doctest_plus_atol
|
||||||
|
|
||||||
|
self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
|
||||||
|
|
||||||
|
../../../lagado2.real/local/anaconda/envs/sherpa-main/lib/python3.11/site-packages/_pytest/config/__init__.py:1373
|
||||||
|
/lagado2.real/local/anaconda/envs/sherpa-main/lib/python3.11/site-packages/_pytest/config/__init__.py:1373: PytestConfigWarning: Unknown config option: doctest_subpackage_requires
|
||||||
|
|
||||||
|
self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
|
||||||
|
|
||||||
|
../../../lagado2.real/local/anaconda/envs/sherpa-main/lib/python3.11/site-packages/_pytest/config/__init__.py:1373
|
||||||
|
/lagado2.real/local/anaconda/envs/sherpa-main/lib/python3.11/site-packages/_pytest/config/__init__.py:1373: PytestConfigWarning: Unknown config option: text_file_format
|
||||||
|
|
||||||
|
self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
|
||||||
|
|
||||||
|
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
||||||
|
================================================= short test summary info =================================================
|
||||||
|
---
|
||||||
|
pytest.ini | 4 ++++
|
||||||
|
1 file changed, 4 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/pytest.ini b/pytest.ini
|
||||||
|
index fde2ab8e0c..e2c4c4847e 100644
|
||||||
|
--- a/pytest.ini
|
||||||
|
+++ b/pytest.ini
|
||||||
|
@@ -2,6 +2,10 @@
|
||||||
|
addopts = -rs --ignore=setup.py --ignore=test_requirements.txt
|
||||||
|
norecursedirs = .git build dist tmp* .eggs
|
||||||
|
text_file_format = rst
|
||||||
|
+filterwarnings =
|
||||||
|
+ # Since we can runpytest without loading pytest-doctestplus, hide
|
||||||
|
+ # the warnings we get when this is done
|
||||||
|
+ ignore::pytest.PytestConfigWarning
|
||||||
|
doctest_plus = enabled
|
||||||
|
doctest_plus_atol = 1e-4
|
||||||
|
doctest_optionflags =
|
||||||
|
|
||||||
|
From 14e43a098ecb9a5068d2886f6d4680b9cd878404 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Doug Burke <dburke@cfa.harvard.edu>
|
||||||
|
Date: Mon, 17 Jul 2023 12:05:21 -0400
|
||||||
|
Subject: [PATCH 2/2] Tests: hide NumPy 1.25 ndim > 0 warnings (crates)
|
||||||
|
|
||||||
|
Although Sherpa has been updated to remove the deprecation
|
||||||
|
warnnng from NumPy 1.25:
|
||||||
|
|
||||||
|
Conversion of an array with ndim > 0 to a scalar is deprecated,
|
||||||
|
and will error in future. Ensure you extract a single element
|
||||||
|
from your array before performing this operation.
|
||||||
|
(Deprecated NumPy 1.25.)
|
||||||
|
|
||||||
|
it is still present in Crates (mid 2023), so hide the warning with
|
||||||
|
the assumption we can revert this commit by mid December 2023.
|
||||||
|
---
|
||||||
|
sherpa/conftest.py | 5 +++++
|
||||||
|
1 file changed, 5 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/sherpa/conftest.py b/sherpa/conftest.py
|
||||||
|
index 97979b4e4b..339f252a51 100644
|
||||||
|
--- a/sherpa/conftest.py
|
||||||
|
+++ b/sherpa/conftest.py
|
||||||
|
@@ -117,6 +117,11 @@ def pytest_collection_modifyitems(config, items):
|
||||||
|
r'np.asscalar\(a\) is deprecated since NumPy v1.16, use a.item\(\) instead',
|
||||||
|
r"Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working",
|
||||||
|
|
||||||
|
+ # NumPy 1.25 warnings that are raised by (mid-2023) crates code.
|
||||||
|
+ # Hopefully this can be removed by December 2023.
|
||||||
|
+ #
|
||||||
|
+ r"Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. \(Deprecated NumPy 1.25.\)",
|
||||||
|
+
|
||||||
|
],
|
||||||
|
UserWarning:
|
||||||
|
[
|
89
numpy125.patch
Normal file
89
numpy125.patch
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
From 740fcd0da87d3aefa41aa3962cc8f1ddb7ab3cab Mon Sep 17 00:00:00 2001
|
||||||
|
From: Doug Burke <dburke@cfa.harvard.edu>
|
||||||
|
Date: Tue, 20 Jun 2023 15:31:55 -0400
|
||||||
|
Subject: [PATCH] NumPy 1.25 support
|
||||||
|
|
||||||
|
NumPy 1.25 deprecates converting a ndarray that is not a 0d value,
|
||||||
|
so for our cases this is
|
||||||
|
|
||||||
|
int(value)
|
||||||
|
info("message %g", value)
|
||||||
|
|
||||||
|
where value is a ndarray of length 1. The simple fix is to explictly
|
||||||
|
access the first element - so
|
||||||
|
|
||||||
|
answer = int(value[0])
|
||||||
|
info("message %g", value[0])
|
||||||
|
|
||||||
|
although for the int case (in the PSF convolution instrument code) I
|
||||||
|
have not looked through to determine if value is always guaranteed to
|
||||||
|
be a ndarray, so it is more like
|
||||||
|
|
||||||
|
if np.isscalar(value):
|
||||||
|
newval = value
|
||||||
|
else:
|
||||||
|
newval = value[0]
|
||||||
|
answer = int(newval)
|
||||||
|
---
|
||||||
|
sherpa/fit.py | 13 +++++++++----
|
||||||
|
sherpa/instrument.py | 12 ++++++++++--
|
||||||
|
2 files changed, 19 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
Index: sherpa-4.15.1/sherpa/fit.py
|
||||||
|
===================================================================
|
||||||
|
--- sherpa-4.15.1.orig/sherpa/fit.py
|
||||||
|
+++ sherpa-4.15.1/sherpa/fit.py
|
||||||
|
@@ -1258,8 +1258,13 @@ class Fit(NoNewAttributesAfterInit):
|
||||||
|
def get_par_name(ii):
|
||||||
|
return self.model.pars[self.thaw_indices[ii]].fullname
|
||||||
|
|
||||||
|
- # Call from a parameter estimation method, to report
|
||||||
|
- # that limits for a given parameter have been found
|
||||||
|
+ # Call from a parameter estimation method, to report that
|
||||||
|
+ # limits for a given parameter have been found At present (mid
|
||||||
|
+ # 2023) it looks like lower/upper are both single-element
|
||||||
|
+ # ndarrays, hence the need to convert to a scalar by accessing
|
||||||
|
+ # the first element (otherwise there's a deprecation warning
|
||||||
|
+ # from NumPy 1.25).
|
||||||
|
+ #
|
||||||
|
def report_progress(i, lower, upper):
|
||||||
|
if i < 0:
|
||||||
|
pass
|
||||||
|
@@ -1268,11 +1273,11 @@ class Fit(NoNewAttributesAfterInit):
|
||||||
|
if isnan(lower) or isinf(lower):
|
||||||
|
info("%s \tlower bound: -----" % name)
|
||||||
|
else:
|
||||||
|
- info("%s \tlower bound: %g" % (name, lower))
|
||||||
|
+ info("%s \tlower bound: %g" % (name, lower[0]))
|
||||||
|
if isnan(upper) or isinf(upper):
|
||||||
|
info("%s \tupper bound: -----" % name)
|
||||||
|
else:
|
||||||
|
- info("%s \tupper bound: %g" % (name, upper))
|
||||||
|
+ info("%s \tupper bound: %g" % (name, upper[0]))
|
||||||
|
|
||||||
|
# If starting fit statistic is chi-squared or C-stat,
|
||||||
|
# can calculate reduced fit statistic -- if it is
|
||||||
|
Index: sherpa-4.15.1/sherpa/instrument.py
|
||||||
|
===================================================================
|
||||||
|
--- sherpa-4.15.1.orig/sherpa/instrument.py
|
||||||
|
+++ sherpa-4.15.1/sherpa/instrument.py
|
||||||
|
@@ -357,9 +357,17 @@ class PSFKernel(Kernel):
|
||||||
|
# and Python 3.8 - causes a TypeError with the message
|
||||||
|
# "only integer scalar arrays can be converted to a scalar index"
|
||||||
|
# to be thrown here if sent directly to set_origin. So
|
||||||
|
- # we convert to a Python integer type.
|
||||||
|
+ # we convert to a Python integer type. In NumPy 1.25 it became
|
||||||
|
+ # a deprecation error to call int on an array with ndim > 0.
|
||||||
|
#
|
||||||
|
- origin = set_origin(kshape, int(brightPixel))
|
||||||
|
+ # assume there is only one element in brightPixel if not
|
||||||
|
+ # a scalar
|
||||||
|
+ #
|
||||||
|
+ if not numpy.isscalar(brightPixel):
|
||||||
|
+ loc = brightPixel[0]
|
||||||
|
+ else:
|
||||||
|
+ loc = brightPixel
|
||||||
|
+ origin = set_origin(kshape, int(loc))
|
||||||
|
|
||||||
|
if self.origin is None:
|
||||||
|
self.origin = origin
|
@ -1,3 +1,8 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Sep 7 12:24:59 UTC 2023 - Markéta Machová <mmachova@suse.com>
|
||||||
|
|
||||||
|
- Add upstream patches numpy125.patch and numpy125-CI.patch
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon May 29 13:52:34 UTC 2023 - Dirk Müller <dmueller@suse.com>
|
Mon May 29 13:52:34 UTC 2023 - Dirk Müller <dmueller@suse.com>
|
||||||
|
|
||||||
|
@ -24,6 +24,10 @@ License: GPL-3.0-only
|
|||||||
URL: https://github.com/sherpa/sherpa/
|
URL: https://github.com/sherpa/sherpa/
|
||||||
Source0: https://github.com/sherpa/sherpa/archive/%{version}.tar.gz#/sherpa-%{version}.tar.gz
|
Source0: https://github.com/sherpa/sherpa/archive/%{version}.tar.gz#/sherpa-%{version}.tar.gz
|
||||||
Source1: https://github.com/sherpa/sherpa-test-data/archive/refs/tags/%{version}.tar.gz#/sherpa-test-data-%{version}.tar.gz
|
Source1: https://github.com/sherpa/sherpa-test-data/archive/refs/tags/%{version}.tar.gz#/sherpa-test-data-%{version}.tar.gz
|
||||||
|
# PATCH-FIX-UPSTREAM https://github.com/sherpa/sherpa/pull/1807 NumPy 1.25 support
|
||||||
|
Patch: numpy125.patch
|
||||||
|
# PATCH-FIX-UPSTREAM https://github.com/sherpa/sherpa/pull/1819 CI: hide NumPy 1.25 array ndim>0 deprecation warnings
|
||||||
|
Patch: numpy125-CI.patch
|
||||||
BuildRequires: %{python_module devel >= 3.8}
|
BuildRequires: %{python_module devel >= 3.8}
|
||||||
BuildRequires: %{python_module numpy-devel >= 1.19}
|
BuildRequires: %{python_module numpy-devel >= 1.19}
|
||||||
BuildRequires: %{python_module pip}
|
BuildRequires: %{python_module pip}
|
||||||
@ -54,7 +58,7 @@ user to construct models from definitions and fit those models to
|
|||||||
data, using a variety of statistics and optimization methods.
|
data, using a variety of statistics and optimization methods.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n sherpa-%{version} -a1
|
%autosetup -p1 -n sherpa-%{version} -a1
|
||||||
# uncomment system libs https://sherpa.readthedocs.io/en/latest/install.html#fftw
|
# uncomment system libs https://sherpa.readthedocs.io/en/latest/install.html#fftw
|
||||||
sed -i "s|#fftw=local|fftw=local|" setup.cfg
|
sed -i "s|#fftw=local|fftw=local|" setup.cfg
|
||||||
sed -i "s|#fftw-include[-_]dirs.*$|fftw-include-dirs=%{_includedir}|" setup.cfg
|
sed -i "s|#fftw-include[-_]dirs.*$|fftw-include-dirs=%{_includedir}|" setup.cfg
|
||||||
|
Loading…
Reference in New Issue
Block a user