From bc76b084765e543679a1687931ffe59bab7903c2 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Sat, 2 Dec 2023 17:46:58 -0500 Subject: [PATCH 1/9] update infrastructure --- .github/workflows/ci.yml | 14 +++++++------- requirements-dev.txt | 6 +++++- setup.cfg | 2 +- setup.py | 5 ----- tox.ini | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5b3e9ba..f53401da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,20 +26,20 @@ jobs: python-version: 3.9 toxenv: py39 - - name: Python 3.8 + - name: Python 3.12 runs-on: ubuntu-latest - python-version: 3.8 - toxenv: py38 + python-version: 3.12 + toxenv: py312 - name: Code style checks runs-on: ubuntu-latest - python-version: 3.8 + python-version: 3.11 toxenv: style - - name: Python 3.8 with dev dependencies + - name: Python 3.11 with dev dependencies runs-on: ubuntu-latest - python-version: 3.8 - toxenv: py38-dev + python-version: 3.11 + toxenv: py311-dev steps: - uses: actions/checkout@v2 with: diff --git a/requirements-dev.txt b/requirements-dev.txt index 37adcf65..f69e6b1b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,6 @@ -git+https://github.com/astropy/astropy.git git+https://github.com/spacetelescope/stsci.tools.git +--extra-index-url https://pypi.anaconda.org/astropy/simple astropy --pre + +# Use Bi-weekly numpy/scipy dev builds +--extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple +numpy>=0.0.dev0 diff --git a/setup.cfg b/setup.cfg index 29ad9073..e6f9d081 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,7 +9,7 @@ edit_on_github = False github_project = spacetelescope/stwcs [tool:pytest] -minversion = 3.6 +minversion = 3.9 norecursedirs = build docs/_build relic filterwarnings= ignore:.*Card is too long* diff --git a/setup.py b/setup.py index 00c47db6..e16656d2 100755 --- a/setup.py +++ b/setup.py @@ -3,11 +3,6 @@ from setuptools import setup, find_packages from configparser import ConfigParser -if sys.version_info < (3, 6): - error = """ - STWCS supports Python 3.6 and above. - """ - sys.exit(error) conf = ConfigParser() conf.read(['setup.cfg']) diff --git a/tox.ini b/tox.ini index d7dd5a58..fc33064e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist= py38, py310, style +envlist= py311, py312, py310, style [testenv] deps= From e3d03cc5238084b139286c628af7d2e50a191a3c Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Sat, 2 Dec 2023 17:56:59 -0500 Subject: [PATCH 2/9] remove pkg_resources --- stwcs/__init__.py | 9 +++++---- stwcs/wcsutil/hstwcs.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/stwcs/__init__.py b/stwcs/__init__.py index 8e39881f..a2465961 100644 --- a/stwcs/__init__.py +++ b/stwcs/__init__.py @@ -14,18 +14,19 @@ """ import os +import importlib.metadata from . import distortion # noqa from stsci.tools import fileutil # noqa from stsci.tools import teal # noqa -from pkg_resources import get_distribution, DistributionNotFound try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: + __version__ = importlib.metadata.version(__name__) + +except importlib.metadata.PackageNotFoundError: # pragma: no cover # package is not installed - pass + pass # pragma: no cover try: from . import gui diff --git a/stwcs/wcsutil/hstwcs.py b/stwcs/wcsutil/hstwcs.py index d19f2144..097c1b04 100644 --- a/stwcs/wcsutil/hstwcs.py +++ b/stwcs/wcsutil/hstwcs.py @@ -478,7 +478,7 @@ def pc2cd(self): @deprecated_renamed_argument('accuracy', 'tolerance', '1.6.1', arg_in_kwargs=True) def all_world2pix(self, *args, **kwargs): """ - all_world2pix(\*arg, tolerance=1.0e-4, maxiter=20, adaptive=False, + all_world2pix(*arg, tolerance=1.0e-4, maxiter=20, adaptive=False, detect_divergence=True, quiet=False) Performs full inverse transformation using iterative solution From e5b5426331c6d199f8423eec9621c53e94be100c Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Sun, 3 Dec 2023 07:42:24 -0500 Subject: [PATCH 3/9] fix rtd build still rtd still rtd still fixing rtd --- .readthedocs.yml | 16 ++++++++++++++-- doc/rtd-pip-requirements | 2 -- doc/rtd_requirements.yaml | 9 +++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) delete mode 100644 doc/rtd-pip-requirements create mode 100644 doc/rtd_requirements.yaml diff --git a/.readthedocs.yml b/.readthedocs.yml index 0e8f7817..7c8c29f0 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,15 +1,27 @@ +# .readthedocs.yaml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required version: 2 sphinx: builder: html configuration: doc/source/conf.py + fail_on_warning: true + +build: + os: ubuntu-22.04 + tools: + python: "3.11" python: - version: 3.8 - system_packages: true install: - method: pip path: . + extra_requirements: + - doc + # Don't build any extra formats formats: [] diff --git a/doc/rtd-pip-requirements b/doc/rtd-pip-requirements deleted file mode 100644 index e5f235d7..00000000 --- a/doc/rtd-pip-requirements +++ /dev/null @@ -1,2 +0,0 @@ -numpy>=1.11 -astropy diff --git a/doc/rtd_requirements.yaml b/doc/rtd_requirements.yaml new file mode 100644 index 00000000..3db3133a --- /dev/null +++ b/doc/rtd_requirements.yaml @@ -0,0 +1,9 @@ +name: rtd311 + +dependencies: + - python=3.11 + - numpy + - astropy + - pip + - graphviz + From d309a83065417bc1dd1d400bb5d9244477015088 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Mon, 4 Dec 2023 08:52:31 -0500 Subject: [PATCH 4/9] rtd and dev --- .github/workflows/ci.yml | 2 +- stwcs/wcsutil/hstwcs.py | 2 +- tox.ini | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f53401da..16f08e31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: - name: Python 3.11 with dev dependencies runs-on: ubuntu-latest python-version: 3.11 - toxenv: py311-dev + toxenv: dev steps: - uses: actions/checkout@v2 with: diff --git a/stwcs/wcsutil/hstwcs.py b/stwcs/wcsutil/hstwcs.py index 097c1b04..d19f2144 100644 --- a/stwcs/wcsutil/hstwcs.py +++ b/stwcs/wcsutil/hstwcs.py @@ -478,7 +478,7 @@ def pc2cd(self): @deprecated_renamed_argument('accuracy', 'tolerance', '1.6.1', arg_in_kwargs=True) def all_world2pix(self, *args, **kwargs): """ - all_world2pix(*arg, tolerance=1.0e-4, maxiter=20, adaptive=False, + all_world2pix(\*arg, tolerance=1.0e-4, maxiter=20, adaptive=False, detect_divergence=True, quiet=False) Performs full inverse transformation using iterative solution diff --git a/tox.ini b/tox.ini index fc33064e..d0012949 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist= py311, py312, py310, style +envlist= py311, py312, py310, style, dev [testenv] deps= From 6dd2992cf52dafbddf62eb97fad2b1c9e4ed8a3a Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Mon, 4 Dec 2023 09:20:58 -0500 Subject: [PATCH 5/9] dev --- requirements-dev.txt | 3 ++- tox.ini | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index f69e6b1b..6c2f308a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,6 @@ git+https://github.com/spacetelescope/stsci.tools.git ---extra-index-url https://pypi.anaconda.org/astropy/simple astropy --pre + +--extra-index-url https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/liberfa/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple astropy --pre # Use Bi-weekly numpy/scipy dev builds --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple diff --git a/tox.ini b/tox.ini index d0012949..e151a5f7 100644 --- a/tox.ini +++ b/tox.ini @@ -2,11 +2,16 @@ envlist= py311, py312, py310, style, dev [testenv] -deps= - dev: -rrequirements-dev.txt + +set_env = + dev: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/liberfa/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple + +commands_pre = + dev: pip install -r requirements-dev.txt -U --upgrade-strategy eager + extras= test -# astropy will complain if the home directory is missing -passenv= HOME + + commands= pytest From dab43d65529281e946f8621384550329323a80a1 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Tue, 5 Dec 2023 08:58:39 -0500 Subject: [PATCH 6/9] remove remnants of relic fix rtd; fis np 2 warnings import sphinx_rtd_theme docs --- .github/workflows/ci.yml | 4 ++-- MANIFEST.in | 1 - doc/rtd_requirements.yaml | 2 +- doc/source/conf.py | 1 + setup.cfg | 7 ++++++- stwcs/tests/test_updatewcs.py | 8 +++++++- stwcs/updatewcs/corrections.py | 4 ++-- 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16f08e31..c83850c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,10 +67,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up Python 3.8 + - name: Set up Python 3.11 uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: 3.11 - name: Install tox run: | python -m pip install --upgrade pip diff --git a/MANIFEST.in b/MANIFEST.in index 19a62f2a..cb99df43 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1 @@ -include RELIC-INFO exclude stwcs/version.py diff --git a/doc/rtd_requirements.yaml b/doc/rtd_requirements.yaml index 3db3133a..c1512bc5 100644 --- a/doc/rtd_requirements.yaml +++ b/doc/rtd_requirements.yaml @@ -6,4 +6,4 @@ dependencies: - astropy - pip - graphviz - + - sphinx_rtd_theme>1.2.0 diff --git a/doc/source/conf.py b/doc/source/conf.py index 6c323d17..9b18616c 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -15,6 +15,7 @@ import importlib # Check Sphinx version import sphinx +import sphinx_rtd_theme # If extensions (or modules to document with autodoc) are in another directory, diff --git a/setup.cfg b/setup.cfg index e6f9d081..1d7c88f2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,7 +10,7 @@ github_project = spacetelescope/stwcs [tool:pytest] minversion = 3.9 -norecursedirs = build docs/_build relic +norecursedirs = build docs/_build filterwarnings= ignore:.*Card is too long* ignore:.*Some non-standard WCS keywords* @@ -22,6 +22,11 @@ filterwarnings= builder = html warning-is-error = 1 +[docs] +docs = + sphinx + sphinx-rtd-theme + [flake8] # E402, E501, E722 should be added back to the selection list # once they are made to pass. diff --git a/stwcs/tests/test_updatewcs.py b/stwcs/tests/test_updatewcs.py index b227e994..c6bc51b4 100644 --- a/stwcs/tests/test_updatewcs.py +++ b/stwcs/tests/test_updatewcs.py @@ -1,8 +1,10 @@ import shutil import os +import warnings from astropy import wcs from astropy.io import fits +from astropy.wcs import FITSFixedWarning from .. import updatewcs from ..updatewcs import apply_corrections from ..distortion import utils as dutils @@ -11,8 +13,9 @@ from numpy import testing import pytest - from . import data + + data_path = os.path.split(os.path.abspath(data.__file__))[0] os.environ['ASTROMETRY_STEP_CONTROL'] = 'Off' @@ -464,6 +467,9 @@ def test_update_stis_asn(): shutil.copyfile(stis_asn_orig_file, fname) shutil.copyfile(idc_orig_file, idctab) + warnings.simplefilter("ignore", category=FITSFixedWarning)#, + # message=" 'datfix' made the change 'Set MJD-OBS to 50853.000000 from DATE-OBS'.") + expnames = updatewcs.updatewcs(fname) assert expnames[0] == os.path.basename(fname_expname1) diff --git a/stwcs/updatewcs/corrections.py b/stwcs/updatewcs/corrections.py index 7dec5686..67349c1f 100644 --- a/stwcs/updatewcs/corrections.py +++ b/stwcs/updatewcs/corrections.py @@ -348,8 +348,8 @@ def updateWCS(cls, ext_wcs, ref_wcs): if n >= m and n >= 2: idcval = np.array([[cx[n, m]], [cy[n, m]]]) sipval = np.dot(imatr, idcval) - akeys1[m, n - m] = sipval[0] - bkeys1[m, n - m] = sipval[1] + akeys1[m, n - m] = sipval[0].item() + bkeys1[m, n - m] = sipval[1].item() Akey = "A_%d_%d" % (m, n - m) Bkey = "B_%d_%d" % (m, n - m) kw2update[Akey] = sipval[0, 0] * ext_wcs.binned, sip_comment From 3b9329bb8fde1d6bc4177caf48da00b77b392288 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Tue, 5 Dec 2023 10:55:16 -0500 Subject: [PATCH 7/9] docs --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 1d7c88f2..c97f4742 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,7 +22,7 @@ filterwarnings= builder = html warning-is-error = 1 -[docs] +[options.extras_require] docs = sphinx sphinx-rtd-theme From e335c8b7823d502fbfe19aabedfaeb278cd405ee Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Tue, 5 Dec 2023 11:15:58 -0500 Subject: [PATCH 8/9] Update .readthedocs.yml Co-authored-by: Zach Burnett --- .readthedocs.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 7c8c29f0..55ec79f3 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -13,7 +13,10 @@ sphinx: build: os: ubuntu-22.04 tools: - python: "3.11" + python: mambaforge-4.10 + +conda: + environment: docs/rtd_requirements.yaml python: install: From 415dd5e71fbc24bc83bb366c86f275393bb89a62 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Tue, 5 Dec 2023 13:11:09 -0500 Subject: [PATCH 9/9] fix path --- .readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 55ec79f3..0b865ca0 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -16,7 +16,7 @@ build: python: mambaforge-4.10 conda: - environment: docs/rtd_requirements.yaml + environment: doc/rtd_requirements.yaml python: install: