Skip to content

Commit

Permalink
Merge pull request #387 from pllim/np-2-astropy-6.1
Browse files Browse the repository at this point in the history
MNT: numpy 2 and astropy 6.1 compat, bump minversions
  • Loading branch information
pllim committed Apr 11, 2024
2 parents d2c71cf + 570f216 commit fc83a69
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 46 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci_workflows.yml
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/predeps_workflow.yml
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.rst
Expand Up @@ -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. [#387]

- Bumped minimum supported versions for Python to 3.10,
``numpy`` to 1.23, ``astropy`` to 6.0, and ``scipy`` to 1.9. [#387]

1.3.0 (2023-11-28)
==================

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Expand Up @@ -42,7 +42,7 @@ reported) or contact `STScI Help Desk <https://hsthelp.stsci.edu>`_.
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
Expand Down
2 changes: 1 addition & 1 deletion 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"
14 changes: 4 additions & 10 deletions setup.cfg
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 =
Expand Down
5 changes: 1 addition & 4 deletions synphot/blackbody.py
Expand Up @@ -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))
Expand Down Expand Up @@ -59,7 +56,7 @@ class BlackBody1D(Fittable1DModel):
>>> from synphot.blackbody import BlackBody1D
>>> bb = BlackBody1D()
>>> bb(6000 * u.AA) # doctest: +FLOAT_CMP
<Quantity 1.3585381201978953e-15 erg / (cm2 Hz s)>
<Quantity 1.35853828e-15 erg / (Hz s cm2)>
.. plot::
:include-source:
Expand Down
7 changes: 1 addition & 6 deletions synphot/compat.py
Expand Up @@ -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):
Expand Down
11 changes: 2 additions & 9 deletions synphot/models.py
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions 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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit fc83a69

Please sign in to comment.