From e742fbd47c8247325ff792e0ec12380b599dac7e Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:49:22 -0400 Subject: [PATCH 1/3] MNT: Build against numpy 2.x and bump minversion of Python and dependencies. --- .github/workflows/ci_workflows.yml | 16 ++++++++-------- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/predeps_workflow.yml | 4 ++-- CHANGES.rst | 6 ++++++ docs/index.rst | 2 +- pyproject.toml | 2 +- setup.cfg | 14 ++++---------- synphot/blackbody.py | 3 --- synphot/compat.py | 7 +------ synphot/models.py | 11 ++--------- tox.ini | 8 ++++---- 11 files changed, 30 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci_workflows.yml b/.github/workflows/ci_workflows.yml index 56efb4e..5e6f481 100644 --- a/.github/workflows/ci_workflows.yml +++ b/.github/workflows/ci_workflows.yml @@ -66,13 +66,13 @@ jobs: - name: Test without optional deps os: ubuntu-latest - python: 3.9 - toxenv: py39-test + python: '3.10' + toxenv: py310-test - name: Coverage test with remote data os: ubuntu-latest - python: '3.10' - toxenv: py310-test-alldeps-cov + python: '3.11' + toxenv: py311-test-alldeps-cov toxposargs: --remote-data - name: Test with dev dependencies @@ -82,13 +82,13 @@ jobs: - name: Test with old dependencies os: ubuntu-20.04 - python: 3.9 - toxenv: py39-test-oldestdeps + python: '3.10' + toxenv: py310-test-oldestdeps - name: Test in OSX os: macos-latest - python: '3.10' - toxenv: py310-test-alldeps + python: '3.12' + toxenv: py312-test-alldeps # NOTE: If TRDS cannot take the hit, disable --remote-data - name: Test in Windows with remote data diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e8ae10c..3441c1c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -74,7 +74,7 @@ jobs: uses: actions/setup-python@v5 if: matrix.language == 'cpp' with: - python-version: 3.9 + python-version: '3.12' - name: Manual build if: matrix.language == 'cpp' diff --git a/.github/workflows/predeps_workflow.yml b/.github/workflows/predeps_workflow.yml index 5659b2b..2196c3f 100644 --- a/.github/workflows/predeps_workflow.yml +++ b/.github/workflows/predeps_workflow.yml @@ -32,8 +32,8 @@ jobs: - name: RC test on Windows os: windows-latest - python: 3.9 - toxenv: py39-test-predeps + python: '3.12' + toxenv: py312-test-predeps steps: - name: Checkout code diff --git a/CHANGES.rst b/CHANGES.rst index eba7947..8f81582 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,6 +10,12 @@ - ``read_spec()`` now detects whether given filename is FITS more consistently w.r.t. ``astropy``. [#384] +- Compatibility with ``numpy`` 2.0 and ``astropy`` 6.1 by building C-extension + against ``numpy`` 2.x ABI. [#381] + +- Bumped minimum supported versions for Python to 3.10, + ``numpy`` to 1.23, ``astropy`` to 6.0, and ``scipy`` to 1.9. [#381] + 1.3.0 (2023-11-28) ================== diff --git a/docs/index.rst b/docs/index.rst index 44bee66..f83c943 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -42,7 +42,7 @@ reported) or contact `STScI Help Desk `_. Installation and Setup ====================== -**synphot** works for Python 3.9 or later only. It requires the following +**synphot** works for Python 3.10 or later only. It requires the following packages: * numpy diff --git a/pyproject.toml b/pyproject.toml index a627153..99bc34c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] requires = ["setuptools>=30.3.0", "setuptools_scm", - "numpy>=1.25"] + "numpy>=2.0.0rc1"] build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index d16facb..0d7d3a1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,9 +5,6 @@ norecursedirs = build docs/_build synphot/src astropy_header = true doctest_plus = enabled doctest_subpackage_requires = - docs/index.rst = astropy>=5.3 - docs/synphot/spectrum.rst = astropy>=5.3 - docs/synphot/tutorials.rst = astropy>=5.3 docs/synphot/filter_par.rst = numpy<2 text_file_format = rst addopts = --doctest-rst --import-mode=append @@ -19,9 +16,6 @@ filterwarnings = ignore:numpy\.ufunc size changed:RuntimeWarning ignore:distutils Version classes are deprecated:DeprecationWarning ignore:Class CCM89 defines class attributes - # Ignore numpy 2.0 warning, see https://github.com/astropy/astropy/pull/15495 - # and https://github.com/scipy/scipy/pull/19275 - ignore:.*numpy\.core.*:DeprecationWarning [metadata] name = synphot @@ -52,10 +46,10 @@ zip_safe = False setup_requires = setuptools_scm install_requires = - numpy>=1.20 - astropy>=5 - scipy>=1.6 -python_requires = >=3.9 + numpy>=1.23 + astropy>=6 + scipy>=1.9 +python_requires = >=3.10 [options.extras_require] all = diff --git a/synphot/blackbody.py b/synphot/blackbody.py index 209e0de..ec45ec9 100644 --- a/synphot/blackbody.py +++ b/synphot/blackbody.py @@ -26,9 +26,6 @@ __all__ = ['BlackBody1D', 'blackbody_nu', 'blackbody_lambda'] -# ASTROPY_LT_5_3 -__doctest_requires__ = {"BlackBody1D": ["astropy<5.3"]} - with warnings.catch_warnings(): warnings.simplefilter('ignore', RuntimeWarning) _has_buggy_expm1 = np.isnan(np.expm1(1000)) or np.isnan(np.expm1(1e10)) diff --git a/synphot/compat.py b/synphot/compat.py index 5c8a4ec..4944973 100644 --- a/synphot/compat.py +++ b/synphot/compat.py @@ -2,15 +2,10 @@ """Module to handle backward-compatibility.""" import importlib -import astropy -from astropy.utils.introspection import minversion - _optional_deps = ['specutils', 'dust_extinction'] _deps = {k.upper(): k for k in _optional_deps} -ASTROPY_LT_5_0 = not minversion(astropy, '5.0') - -__all__ = ['ASTROPY_LT_5_0'] + [f"HAS_{pkg}" for pkg in _deps] +__all__ = [f"HAS_{pkg}" for pkg in _deps] def __getattr__(name): diff --git a/synphot/models.py b/synphot/models.py index 2a2cc0a..53be9b2 100644 --- a/synphot/models.py +++ b/synphot/models.py @@ -23,7 +23,6 @@ # LOCAL from synphot import units -from synphot.compat import ASTROPY_LT_5_0 from synphot.exceptions import SynphotError from synphot.utils import merge_wavelengths @@ -228,10 +227,7 @@ def sampleset(self, step=None, minimal=False): if step is None: step = self.step - if ASTROPY_LT_5_0: - w1, w2 = self.bounding_box - else: - w1, w2 = tuple(self.bounding_box.bounding_box()) + w1, w2 = tuple(self.bounding_box.bounding_box()) if self._n_models == 1: w = self._calc_sampleset(w1, w2, step, minimal) @@ -763,10 +759,7 @@ class Trapezoid1D(_models.Trapezoid1D): """ def sampleset(self): """Return ``x`` array that samples the feature.""" - if ASTROPY_LT_5_0: - x1, x4 = self.bounding_box - else: - x1, x4 = tuple(self.bounding_box.bounding_box()) + x1, x4 = tuple(self.bounding_box.bounding_box()) dw = self.width * 0.5 x2 = self.x_0 - dw x3 = self.x_0 + dw diff --git a/tox.ini b/tox.ini index 12d52f5..bb0c795 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{39,310,311,312}-test{,-alldeps,-oldestdeps,-devdeps,-predeps}{,-cov} + py{310,311,312}-test{,-alldeps,-oldestdeps,-devdeps,-predeps}{,-cov} codestyle twine bandit @@ -36,9 +36,9 @@ deps = # The oldestdeps factor is intended to be used to install the oldest versions of all # dependencies that have a minimum version. - oldestdeps: numpy==1.20.* - oldestdeps: scipy==1.6.* - oldestdeps: astropy==5.0.* + oldestdeps: numpy==1.23.* + oldestdeps: scipy==1.9.* + oldestdeps: astropy==6.0.* # The devdeps factor is intended to be used to install the latest developer version # or nightly wheel of key dependencies. From 21514acf2ef0b0857dd13a02e146bbcccbcdfe19 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Fri, 5 Apr 2024 18:33:36 -0400 Subject: [PATCH 2/3] TST: Update blackbody doctest result --- synphot/blackbody.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synphot/blackbody.py b/synphot/blackbody.py index ec45ec9..52e78a4 100644 --- a/synphot/blackbody.py +++ b/synphot/blackbody.py @@ -56,7 +56,7 @@ class BlackBody1D(Fittable1DModel): >>> from synphot.blackbody import BlackBody1D >>> bb = BlackBody1D() >>> bb(6000 * u.AA) # doctest: +FLOAT_CMP - + .. plot:: :include-source: From 570f216bafe24e43a68f7f387fa9df4a1b0680c6 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Fri, 5 Apr 2024 19:06:12 -0400 Subject: [PATCH 3/3] Fix change log --- CHANGES.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 8f81582..85a4170 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,10 +11,10 @@ w.r.t. ``astropy``. [#384] - Compatibility with ``numpy`` 2.0 and ``astropy`` 6.1 by building C-extension - against ``numpy`` 2.x ABI. [#381] + against ``numpy`` 2.x ABI. [#387] - Bumped minimum supported versions for Python to 3.10, - ``numpy`` to 1.23, ``astropy`` to 6.0, and ``scipy`` to 1.9. [#381] + ``numpy`` to 1.23, ``astropy`` to 6.0, and ``scipy`` to 1.9. [#387] 1.3.0 (2023-11-28) ==================