From 1a21012753745fb85d5cfe7734d988e7d97cb04f Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Thu, 1 Aug 2024 14:31:17 -0700 Subject: [PATCH 01/12] update test infrastructure --- .github/workflows/python-package.yml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 1f5df85..a455928 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -27,12 +27,12 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -40,7 +40,6 @@ jobs: run: | python -m pip install --upgrade pip wheel setuptools python -m pip install pytest pytest-astropy pyyaml - # python -m pip install -r requirements.txt python -m pip install 'scipy${{ matrix.scipy-version }}' python -m pip install 'matplotlib${{ matrix.matplotlib-version }}' python -m pip install 'astropy${{ matrix.astropy-version }}' @@ -59,12 +58,12 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -90,22 +89,22 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: [3.9] + python-version: ['3.10'] steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Python dependencies run: | - python -m pip install --upgrade pip wheel setuptools docutils\<0.18 Sphinx + python -m pip install --upgrade pip wheel setuptools docutils Sphinx python -m pip install sphinx-astropy python -m pip install speclite @@ -119,16 +118,16 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: [3.9] + python-version: ['3.10'] steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} From 8414c30b74a8631b22a2e19ebfb66ce4ab881a28 Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Thu, 1 Aug 2024 14:52:49 -0700 Subject: [PATCH 02/12] add tests and clean up --- .github/workflows/python-package.yml | 2 +- speclite/conftest.py | 13 +++++++------ speclite/filters.py | 15 +++++++++------ speclite/tests/test_accumulate.py | 2 -- speclite/tests/test_utils.py | 9 +++++++++ 5 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 speclite/tests/test_utils.py diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index a455928..62db1c5 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -104,7 +104,7 @@ jobs: - name: Install Python dependencies run: | - python -m pip install --upgrade pip wheel setuptools docutils Sphinx + python -m pip install --upgrade pip wheel setuptools Sphinx\<8 python -m pip install sphinx-astropy python -m pip install speclite diff --git a/speclite/conftest.py b/speclite/conftest.py index 782d3ed..deeede0 100644 --- a/speclite/conftest.py +++ b/speclite/conftest.py @@ -24,12 +24,13 @@ ## the list of packages for which version numbers are displayed when running ## the tests. Making it pass for KeyError is essential in some cases when ## the package uses other astropy affiliated packages. -# try: -# PYTEST_HEADER_MODULES['Astropy'] = 'astropy' -# PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' -# del PYTEST_HEADER_MODULES['h5py'] -# except (NameError, KeyError): # NameError is needed to support Astropy < 1.0 -# pass +try: + PYTEST_HEADER_MODULES['Astropy'] = 'astropy' + PYTEST_HEADER_MODULES['PIL'] = 'pillow' + del PYTEST_HEADER_MODULES['h5py'] + del PYTEST_HEADER_MODULES['pandas'] +except (NameError, KeyError): # NameError is needed to support Astropy < 1.0 + pass ## Uncomment the following lines to display the version number of the ## package rather than the version number of Astropy in the top line when diff --git a/speclite/filters.py b/speclite/filters.py index 8928203..b4dfba4 100644 --- a/speclite/filters.py +++ b/speclite/filters.py @@ -237,7 +237,12 @@ import numpy as np import scipy.interpolate -import scipy.integrate + +try: + from scipy.integrate import trapezoid as trapz + from scipy.integrate import simpson as simps +except ModuleNotFoundError: + from scipy.integrate import trapz, simps import astropy.table import astropy.units @@ -267,9 +272,7 @@ _photon_weighted_unit = default_wavelength_unit**2 / _hc_constant.unit # Map names to integration methods allowed by the convolution methods below. -_filter_integration_methods = dict( - trapz= scipy.integrate.trapz, - simps= scipy.integrate.simps) +_filter_integration_methods = dict(trapz=trapz, simps=simps) # Group and band names must be valid python identifiers. Although a leading # underscore is probably not a good idea, it is simpler to stick with a @@ -1806,7 +1809,7 @@ def load_filters(*names): """ # Replace any group wildcards with the corresponding canonical names. - + filters_path = get_path_of_data_file('filters/') @@ -1945,7 +1948,7 @@ def load_filter(name, load_from_cache=True, verbose=False): def plot_filters(responses, wavelength_unit=None, wavelength_limits=None, wavelength_scale='linear', - legend_loc='upper right', legend_ncols=1, + legend_loc='upper right', legend_ncols=1, response_limits=None, cmap='nipy_spectral'): """Plot one or more filter response curves. diff --git a/speclite/tests/test_accumulate.py b/speclite/tests/test_accumulate.py index b5be488..816511c 100644 --- a/speclite/tests/test_accumulate.py +++ b/speclite/tests/test_accumulate.py @@ -1,6 +1,4 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst -from __future__ import print_function, division - from astropy.tests.helper import pytest from ..accumulate import accumulate import numpy as np diff --git a/speclite/tests/test_utils.py b/speclite/tests/test_utils.py new file mode 100644 index 0000000..e907e39 --- /dev/null +++ b/speclite/tests/test_utils.py @@ -0,0 +1,9 @@ +from ..utils.package_data import get_path_of_data_file, get_path_of_data_dir + + +def test_get_path_of_data_file(): + pass + + +def test_get_path_of_data_dir(): + pass From fba98142d6d7c3906a7cf7e5829c4e8779e7743c Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Thu, 1 Aug 2024 15:15:51 -0700 Subject: [PATCH 03/12] add duplicate conftest.py --- conftest.py | 52 ++++++++++++++++++++++++++++++++++ speclite/conftest.py | 5 ++-- speclite/resample.py | 8 +++--- speclite/tests/test_utils.py | 9 ++++-- speclite/utils/package_data.py | 16 ++++------- 5 files changed, 71 insertions(+), 19 deletions(-) create mode 100644 conftest.py diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000..53f2bbe --- /dev/null +++ b/conftest.py @@ -0,0 +1,52 @@ +# this contains imports plugins that configure py.test for astropy tests. +# by importing them here in conftest.py they are discoverable by py.test +# no matter how it is invoked within the source tree. + +from astropy.version import version as astropy_version +if astropy_version < '3.0': + # With older versions of Astropy, we actually need to import the pytest + # plugins themselves in order to make them discoverable by pytest. + from astropy.tests.pytest_plugins import * +else: + # As of Astropy 3.0, the pytest plugins provided by Astropy are + # automatically made available when Astropy is installed. This means it's + # not necessary to import them here, but we still need to import global + # variables that are used for configuration. + from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS + +from astropy.tests.helper import enable_deprecations_as_exceptions + +## Uncomment the following line to treat all DeprecationWarnings as +## exceptions +# enable_deprecations_as_exceptions() + +## Uncomment and customize the following lines to add/remove entries from +## the list of packages for which version numbers are displayed when running +## the tests. Making it pass for KeyError is essential in some cases when +## the package uses other astropy affiliated packages. +try: + PYTEST_HEADER_MODULES['Astropy'] = 'astropy' + PYTEST_HEADER_MODULES['Pillow'] = 'PIL' + PYTEST_HEADER_MODULES['PyYAML'] = 'yaml' + del PYTEST_HEADER_MODULES['h5py'] + del PYTEST_HEADER_MODULES['Pandas'] +except (NameError, KeyError): # NameError is needed to support Astropy < 1.0 + pass + +## Uncomment the following lines to display the version number of the +## package rather than the version number of Astropy in the top line when +## running the tests. +# import os +# +## This is to figure out the affiliated package version, rather than +## using Astropy's +# try: +# from .version import version +# except ImportError: +# version = 'dev' +# +# try: +# packagename = os.path.basename(os.path.dirname(__file__)) +# TESTED_VERSIONS[packagename] = version +# except NameError: # Needed to support Astropy <= 1.0.0 +# pass diff --git a/speclite/conftest.py b/speclite/conftest.py index deeede0..53f2bbe 100644 --- a/speclite/conftest.py +++ b/speclite/conftest.py @@ -26,9 +26,10 @@ ## the package uses other astropy affiliated packages. try: PYTEST_HEADER_MODULES['Astropy'] = 'astropy' - PYTEST_HEADER_MODULES['PIL'] = 'pillow' + PYTEST_HEADER_MODULES['Pillow'] = 'PIL' + PYTEST_HEADER_MODULES['PyYAML'] = 'yaml' del PYTEST_HEADER_MODULES['h5py'] - del PYTEST_HEADER_MODULES['pandas'] + del PYTEST_HEADER_MODULES['Pandas'] except (NameError, KeyError): # NameError is needed to support Astropy < 1.0 pass diff --git a/speclite/resample.py b/speclite/resample.py index b77fa28..110132d 100644 --- a/speclite/resample.py +++ b/speclite/resample.py @@ -6,9 +6,9 @@ import numpy as np import numpy.ma as ma import scipy.interpolate -import pkg_resources as pkgr +from packaging import version -if pkgr.parse_version(np.__version__) >= pkgr.parse_version('1.16'): +if version.parse(np.__version__) >= version.parse('1.16'): import numpy.lib.recfunctions as rfn def resample(data_in, x_in, x_out, y, data_out=None, kind='linear'): @@ -168,7 +168,7 @@ def resample(data_in, x_in, x_out, y, data_out=None, kind='linear'): for i,y in enumerate(y_names): y_in[:,i] = data_in[y].filled(np.nan) else: - if pkgr.parse_version(np.__version__) >= pkgr.parse_version('1.16'): + if version.parse(np.__version__) >= version.parse('1.16'): # The slicing does not work in numpy 1.16 and above # we use structured_to_unstructured to get the slice that we care about y_in = rfn.structured_to_unstructured( @@ -178,7 +178,7 @@ def resample(data_in, x_in, x_out, y, data_out=None, kind='linear'): # View the structured 1D array as a 2D unstructured array (without # copying any memory). y_in = y_in.view(y_type).reshape(data_in.shape + y_shape) - + # interp1d will only propagate NaNs correctly for certain values of `kind`. # With numpy = 1.6 or 1.7, only 'nearest' and 'linear' work. # With numpy = 1.8 or 1.9, 'slinear' and kind = 0 or 1 also work. diff --git a/speclite/tests/test_utils.py b/speclite/tests/test_utils.py index e907e39..138ab8c 100644 --- a/speclite/tests/test_utils.py +++ b/speclite/tests/test_utils.py @@ -1,9 +1,14 @@ +import os +import pathlib from ..utils.package_data import get_path_of_data_file, get_path_of_data_dir def test_get_path_of_data_file(): - pass + data_file = get_path_of_data_file('filters/twomass-Ks.ecsv') + assert os.path.exists(data_file) def test_get_path_of_data_dir(): - pass + data_dir = get_path_of_data_dir() + assert isinstance(data_dir, pathlib.PosixPath) + assert os.path.isdir(data_dir) diff --git a/speclite/utils/package_data.py b/speclite/utils/package_data.py index 59f753a..f95bf56 100644 --- a/speclite/utils/package_data.py +++ b/speclite/utils/package_data.py @@ -1,21 +1,15 @@ import os - -import pkg_resources +from importlib import resources # TODO: should make these Path objects -def get_path_of_data_file(data_file) -> str: +def get_path_of_data_file(data_file): """convenience wrapper to return location of data file """ - file_path = pkg_resources.resource_filename( - "speclite", os.path.join("data", f"{data_file}")) - - return file_path + return os.path.join(str(get_path_of_data_dir()), data_file) -def get_path_of_data_dir() -> str: +def get_path_of_data_dir(): """convenience wrapper to return location of data directory """ - file_path = pkg_resources.resource_filename("speclite", "data") - - return file_path + return resources.files('speclite') / 'data' From 0943a8de501ca0cea0a0030b25dfadb7a3d28287 Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Thu, 1 Aug 2024 15:20:57 -0700 Subject: [PATCH 04/12] fix import error --- .github/workflows/python-package.yml | 6 +++--- speclite/filters.py | 2 +- speclite/tests/test_filters.py | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 62db1c5..1d60b09 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -135,7 +135,7 @@ jobs: run: | python -m pip install --upgrade pip wheel setuptools flake8 - - name: Test the style; failures are allowed - # This is equivalent to an allowed falure. - continue-on-error: true + - name: Test the style + # If allowed failures are needed, uncomment continue-on-error. + # continue-on-error: true run: flake8 speclite --count --max-line-length=100 diff --git a/speclite/filters.py b/speclite/filters.py index b4dfba4..06e5a66 100644 --- a/speclite/filters.py +++ b/speclite/filters.py @@ -241,7 +241,7 @@ try: from scipy.integrate import trapezoid as trapz from scipy.integrate import simpson as simps -except ModuleNotFoundError: +except ImportError: from scipy.integrate import trapz, simps import astropy.table diff --git a/speclite/tests/test_filters.py b/speclite/tests/test_filters.py index 4a5187a..5be7916 100644 --- a/speclite/tests/test_filters.py +++ b/speclite/tests/test_filters.py @@ -1,6 +1,4 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst -from __future__ import print_function, division - from astropy.tests.helper import pytest from ..filters import * @@ -261,7 +259,7 @@ def test_wavelength_property(): wlen = [1, 2, 3] * u.Angstrom meta = dict(group_name='g', band_name='b') r = FilterResponse(wlen, [0,1,0], meta) - assert np.allclose(r.wavelength, r._wavelength) + assert np.allclose(r.wavelength, r._wavelength) assert np.allclose(r.wavelength, validate_wavelength_array(wlen)) def test_mag_flux_units(): From a2fdce0ef5efcf2b4ca172507429958b090babdb Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Thu, 1 Aug 2024 15:44:55 -0700 Subject: [PATCH 05/12] exclude some functions from tests --- docs/api.rst | 2 +- speclite/tests/test_utils.py | 19 ++++++++++++++----- speclite/utils/package_data.py | 15 ++++++++++++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 3f785b1..6d9556a 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -20,7 +20,7 @@ Operations with Filters .. automodapi:: speclite.filters :no-inheritance-diagram: - :skip: get_path_of_data_file + :skip: get_path_of_data_file, trapz, simps Other Functions =============== diff --git a/speclite/tests/test_utils.py b/speclite/tests/test_utils.py index 138ab8c..fe527aa 100644 --- a/speclite/tests/test_utils.py +++ b/speclite/tests/test_utils.py @@ -1,14 +1,23 @@ import os -import pathlib -from ..utils.package_data import get_path_of_data_file, get_path_of_data_dir +from ..utils import package_data def test_get_path_of_data_file(): - data_file = get_path_of_data_file('filters/twomass-Ks.ecsv') + data_file = package_data.get_path_of_data_file('filters/twomass-Ks.ecsv') assert os.path.exists(data_file) def test_get_path_of_data_dir(): - data_dir = get_path_of_data_dir() - assert isinstance(data_dir, pathlib.PosixPath) + data_dir = package_data.get_path_of_data_dir() assert os.path.isdir(data_dir) + + +def test_get_path_of_data_dir_no_importlib(monkeypatch): + data_dir = package_data.get_path_of_data_dir() + def mock_resource(foo, bar): + return data_dir + monkeypatch.setattr(package_data, '_has_importlib', False) + monkeypatch.setattr(package_data, 'resource_filename', mock_resource) + data_dir2 = package_data.get_path_of_data_dir() + assert data_dir2 == data_dir + diff --git a/speclite/utils/package_data.py b/speclite/utils/package_data.py index f95bf56..c661563 100644 --- a/speclite/utils/package_data.py +++ b/speclite/utils/package_data.py @@ -1,15 +1,24 @@ import os -from importlib import resources + +_has_importlib = True +try: + from importlib.resources import files + resource_filename = None +except ImportError: + from pkg_resources import resource_filename + _has_importlib = False # TODO: should make these Path objects def get_path_of_data_file(data_file): """convenience wrapper to return location of data file """ - return os.path.join(str(get_path_of_data_dir()), data_file) + return os.path.join(get_path_of_data_dir(), data_file) def get_path_of_data_dir(): """convenience wrapper to return location of data directory """ - return resources.files('speclite') / 'data' + if _has_importlib: + return str(files('speclite') / 'data') + return resource_filename('speclite', 'data') From 0c522d446e6d818f8bf86f021f65e1973195f314 Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Thu, 1 Aug 2024 15:59:41 -0700 Subject: [PATCH 06/12] working on doc test --- .github/workflows/python-package.yml | 3 +-- setup.cfg | 4 +++- speclite/tests/test_utils.py | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 1d60b09..cc48c0d 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -89,7 +89,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: ['3.10'] + python-version: ['3.8'] steps: - name: Checkout code @@ -106,7 +106,6 @@ jobs: run: | python -m pip install --upgrade pip wheel setuptools Sphinx\<8 python -m pip install sphinx-astropy - python -m pip install speclite - name: Test the documentation run: sphinx-build -W --keep-going -b html docs docs/_build/html diff --git a/setup.cfg b/setup.cfg index 1110016..909577c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,7 @@ license = BSD url = https://speclite.readthedocs.io/ edit_on_github = True github_project = desihub/speclite -install_requires = astropy scipy pyyaml pytest_astropy_header +install_requires = astropy scipy pyyaml # version should be PEP440 compatible, e.g. 0.8 or 0.8.dev (http://www.python.org/dev/peps/pep-0440) version = 0.20.dev @@ -36,6 +36,8 @@ version = 0.20.dev speclite_benchmark = speclite.benchmark:main [options.extras_require] +test = + pytest-astropy docs = sphinx-astropy diff --git a/speclite/tests/test_utils.py b/speclite/tests/test_utils.py index fe527aa..4e234e5 100644 --- a/speclite/tests/test_utils.py +++ b/speclite/tests/test_utils.py @@ -20,4 +20,3 @@ def mock_resource(foo, bar): monkeypatch.setattr(package_data, 'resource_filename', mock_resource) data_dir2 = package_data.get_path_of_data_dir() assert data_dir2 == data_dir - From e5d00a5ceb9191cf02192a3b97e21fd8928e48bc Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Thu, 1 Aug 2024 16:21:15 -0700 Subject: [PATCH 07/12] tweaking tests --- .github/workflows/python-package.yml | 10 +++++----- docs/conf.py | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index cc48c0d..c29d1ac 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -19,11 +19,11 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] # Add more os? - python-version: [3.8, 3.9] + python-version: ['3.8', '3.9'] astropy-version: ['<5.0', '<5.1'] numpy-version: ['<1.20', '<1.21', '<1.22'] scipy-version: ['<1.6', '<1.7'] - matplotlib-version: ['<3.4', '<3.5'] + matplotlib-version: ['<3.3'] # '<3.4', '<3.5'] steps: - name: Checkout code @@ -70,8 +70,8 @@ jobs: - name: Install Python dependencies run: | python -m pip install --upgrade pip wheel setuptools - python -m pip install pytest pytest-astropy coveralls - python -m pip install pyyaml numpy\<1.21 scipy\<1.6 matplotlib\<3.3 astropy\<5.0 + python -m pip install pytest pytest-astropy pyyaml coveralls + python -m pip install numpy\<1.21 scipy\<1.6 matplotlib\<3.3 astropy\<5.0 - name: Run the test with coverage run: pytest --cov @@ -105,7 +105,7 @@ jobs: - name: Install Python dependencies run: | python -m pip install --upgrade pip wheel setuptools Sphinx\<8 - python -m pip install sphinx-astropy + python -m pip install -e .[docs] - name: Test the documentation run: sphinx-build -W --keep-going -b html docs docs/_build/html diff --git a/docs/conf.py b/docs/conf.py index 445fee2..7e2f9c7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -28,6 +28,7 @@ import datetime import os import sys +from importlib import import_module try: import astropy_helpers @@ -84,7 +85,7 @@ # |version| and |release|, also used in various other places throughout the # built documents. -__import__(setup_cfg['package_name']) +import_module(setup_cfg['package_name']) package = sys.modules[setup_cfg['package_name']] # The short X.Y version. From 976ca1276191a556928a07c96f792ff326e27556 Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Thu, 1 Aug 2024 16:38:36 -0700 Subject: [PATCH 08/12] test pinning pillow --- .github/workflows/python-package.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index c29d1ac..b95eb19 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -23,6 +23,7 @@ jobs: astropy-version: ['<5.0', '<5.1'] numpy-version: ['<1.20', '<1.21', '<1.22'] scipy-version: ['<1.6', '<1.7'] + # matplotlib >= 3.3 brings in a dependency on Pillow, which requires numpy >= 1.21 (unless it's pinned. Maybe Pillow <10.1?) matplotlib-version: ['<3.3'] # '<3.4', '<3.5'] steps: @@ -71,7 +72,7 @@ jobs: run: | python -m pip install --upgrade pip wheel setuptools python -m pip install pytest pytest-astropy pyyaml coveralls - python -m pip install numpy\<1.21 scipy\<1.6 matplotlib\<3.3 astropy\<5.0 + python -m pip install Pillow\<10.1 numpy\<1.21 scipy\<1.6 matplotlib\<3.4 astropy\<5.0 - name: Run the test with coverage run: pytest --cov From 42d1ab057ae712255c1281ad1eafd1f643dea191 Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Thu, 1 Aug 2024 16:42:21 -0700 Subject: [PATCH 09/12] further tests of pillow version --- .github/workflows/python-package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index b95eb19..4b4e5cc 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -24,7 +24,7 @@ jobs: numpy-version: ['<1.20', '<1.21', '<1.22'] scipy-version: ['<1.6', '<1.7'] # matplotlib >= 3.3 brings in a dependency on Pillow, which requires numpy >= 1.21 (unless it's pinned. Maybe Pillow <10.1?) - matplotlib-version: ['<3.3'] # '<3.4', '<3.5'] + matplotlib-version: ['<3.4'] # '<3.5'] steps: - name: Checkout code @@ -40,7 +40,7 @@ jobs: - name: Install Python dependencies run: | python -m pip install --upgrade pip wheel setuptools - python -m pip install pytest pytest-astropy pyyaml + python -m pip install pytest pytest-astropy pyyaml Pillow\<10.1 python -m pip install 'scipy${{ matrix.scipy-version }}' python -m pip install 'matplotlib${{ matrix.matplotlib-version }}' python -m pip install 'astropy${{ matrix.astropy-version }}' @@ -72,7 +72,7 @@ jobs: run: | python -m pip install --upgrade pip wheel setuptools python -m pip install pytest pytest-astropy pyyaml coveralls - python -m pip install Pillow\<10.1 numpy\<1.21 scipy\<1.6 matplotlib\<3.4 astropy\<5.0 + python -m pip install Pillow\<10.2 numpy\<1.21 scipy\<1.6 matplotlib\<3.4 astropy\<5.0 - name: Run the test with coverage run: pytest --cov From 738a718f1946406fb47baa644f58d7abdd687c83 Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Thu, 1 Aug 2024 16:44:59 -0700 Subject: [PATCH 10/12] restore matplotlib 3.4 --- .github/workflows/python-package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 4b4e5cc..158990f 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -24,7 +24,7 @@ jobs: numpy-version: ['<1.20', '<1.21', '<1.22'] scipy-version: ['<1.6', '<1.7'] # matplotlib >= 3.3 brings in a dependency on Pillow, which requires numpy >= 1.21 (unless it's pinned. Maybe Pillow <10.1?) - matplotlib-version: ['<3.4'] # '<3.5'] + matplotlib-version: ['<3.4', '<3.5'] steps: - name: Checkout code @@ -40,7 +40,7 @@ jobs: - name: Install Python dependencies run: | python -m pip install --upgrade pip wheel setuptools - python -m pip install pytest pytest-astropy pyyaml Pillow\<10.1 + python -m pip install pytest pytest-astropy pyyaml Pillow\<10.2 python -m pip install 'scipy${{ matrix.scipy-version }}' python -m pip install 'matplotlib${{ matrix.matplotlib-version }}' python -m pip install 'astropy${{ matrix.astropy-version }}' @@ -72,7 +72,7 @@ jobs: run: | python -m pip install --upgrade pip wheel setuptools python -m pip install pytest pytest-astropy pyyaml coveralls - python -m pip install Pillow\<10.2 numpy\<1.21 scipy\<1.6 matplotlib\<3.4 astropy\<5.0 + python -m pip install Pillow\<10.3 numpy\<1.21 scipy\<1.6 matplotlib\<3.4 astropy\<5.0 - name: Run the test with coverage run: pytest --cov From ea11ae0936d8959d7ead06f4f146867b09c56b1f Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Thu, 1 Aug 2024 16:51:06 -0700 Subject: [PATCH 11/12] creep up on pillow 10.4 --- .github/workflows/python-package.yml | 4 ++-- speclite/filters.py | 3 +-- speclite/resample.py | 2 -- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 158990f..9ae366a 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -40,7 +40,7 @@ jobs: - name: Install Python dependencies run: | python -m pip install --upgrade pip wheel setuptools - python -m pip install pytest pytest-astropy pyyaml Pillow\<10.2 + python -m pip install pytest pytest-astropy pyyaml Pillow\<10.3 python -m pip install 'scipy${{ matrix.scipy-version }}' python -m pip install 'matplotlib${{ matrix.matplotlib-version }}' python -m pip install 'astropy${{ matrix.astropy-version }}' @@ -72,7 +72,7 @@ jobs: run: | python -m pip install --upgrade pip wheel setuptools python -m pip install pytest pytest-astropy pyyaml coveralls - python -m pip install Pillow\<10.3 numpy\<1.21 scipy\<1.6 matplotlib\<3.4 astropy\<5.0 + python -m pip install Pillow\<10.4 numpy\<1.21 scipy\<1.6 matplotlib\<3.4 astropy\<5.0 - name: Run the test with coverage run: pytest --cov diff --git a/speclite/filters.py b/speclite/filters.py index 06e5a66..75e30a9 100644 --- a/speclite/filters.py +++ b/speclite/filters.py @@ -239,8 +239,7 @@ import scipy.interpolate try: - from scipy.integrate import trapezoid as trapz - from scipy.integrate import simpson as simps + from scipy.integrate import trapezoid as trapz, simpson as simps except ImportError: from scipy.integrate import trapz, simps diff --git a/speclite/resample.py b/speclite/resample.py index 110132d..bb722ba 100644 --- a/speclite/resample.py +++ b/speclite/resample.py @@ -1,8 +1,6 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst """Resample spectra using interpolation. """ -from __future__ import print_function, division - import numpy as np import numpy.ma as ma import scipy.interpolate From 869b8801d4dce53d9c5ac5d0828b5d9212fa68a2 Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Thu, 1 Aug 2024 17:06:36 -0700 Subject: [PATCH 12/12] finalize pillow version --- .github/workflows/python-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 9ae366a..a9200b1 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -23,7 +23,7 @@ jobs: astropy-version: ['<5.0', '<5.1'] numpy-version: ['<1.20', '<1.21', '<1.22'] scipy-version: ['<1.6', '<1.7'] - # matplotlib >= 3.3 brings in a dependency on Pillow, which requires numpy >= 1.21 (unless it's pinned. Maybe Pillow <10.1?) + # matplotlib >= 3.3 brings in a dependency on Pillow, which requires numpy >= 1.21 unless it's pinned to Pillow<10.4. matplotlib-version: ['<3.4', '<3.5'] steps: @@ -40,7 +40,7 @@ jobs: - name: Install Python dependencies run: | python -m pip install --upgrade pip wheel setuptools - python -m pip install pytest pytest-astropy pyyaml Pillow\<10.3 + python -m pip install pytest pytest-astropy pyyaml Pillow\<10.4 python -m pip install 'scipy${{ matrix.scipy-version }}' python -m pip install 'matplotlib${{ matrix.matplotlib-version }}' python -m pip install 'astropy${{ matrix.astropy-version }}'