Skip to content

Commit

Permalink
MNT: Infrastructure and other updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed Dec 5, 2023
1 parent aa4ceab commit 6b14578
Show file tree
Hide file tree
Showing 34 changed files with 420 additions and 517 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 100
59 changes: 21 additions & 38 deletions .github/workflows/cron-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,31 @@
name: Weekly Tests

on:
pull_request:
# We also want this workflow triggered if the 'Extra CI' label is added
# or present when PR is updated
types:
- synchronize
- labeled
schedule:
# run every Monday at 6am UTC
- cron: '0 6 * * 1'

env:
TOXARGS: '-v'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# Set up matrix to run tox tests across lists of os, python version, and tox environment
matrix_tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Github actions supports ubuntu, windows, and macos virtual environments:
# https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
#
# Only run on ubuntu by default, but can add other os's to the test matrix here.
# For example -- os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
python: '3.11'
tox_env: 'linkcheck'
- os: ubuntu-latest
python: '3.12'
tox_env: 'py312-test-devdeps'
- os: ubuntu-latest
python: '3.12'
tox_env: 'py312-test-predeps'
tests:
if: (github.repository == 'astropy/specreduce' && (github.event_name == 'schedule' || github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'Extra CI')))
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
submodules: false
coverage: ''
envs: |
- name: Check URLs in docs
linux: linkcheck
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up python ${{ matrix.python }} with tox environment ${{ matrix.tox_env }} on ${{ matrix.os }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}
- name: Install base dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
- name: Test with tox
run: |
tox -e ${{ matrix.tox_env }}
- name: Python 3.12 on Linux with pre-releases
linux: py312-test-alldeps-predeps
toxargs: -v
88 changes: 34 additions & 54 deletions .github/workflows/tox-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,64 +11,44 @@ on:
tags:
- '*'
pull_request:
schedule:
# run every Monday at 6am UTC
- cron: '0 6 * * 1'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
TOXARGS: '-v'

jobs:
# Set up matrix to run tox tests across lists of os, python version, and tox environment
matrix_tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Github actions supports ubuntu, windows, and macos virtual environments:
# https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
#
# Only run on ubuntu by default, but can add other os's to the test matrix here.
# For example -- os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
python: '3.10'
tox_env: 'py310-test-cov'
- os: ubuntu-latest
python: '3.11'
tox_env: 'py311-test'
- os: ubuntu-latest
python: '3.12'
tox_env: 'py312-test'
- os: macos-latest
python: '3.12'
tox_env: 'py312-test-devdeps'
- os: ubuntu-latest
python: '3.12'
tox_env: 'codestyle'
- os: ubuntu-latest
python: '3.10'
tox_env: 'py310-test-oldestdeps'
tests:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV }}
with:
submodules: false
coverage: ''
envs: |
- name: Codestyle
linux: codestyle
- name: Python 3.8 on Linux with oldest supported dependencies
linux: py38-test-oldestdeps
toxargs: -v
- name: Python 3.9 on Windows with minimal dependencies
windows: py39-test
toxargs: -v
- name: Python 3.10 on OSX with minimal dependencies
macos: py310-test
toxargs: -v
- name: Python 3.11 on Linux with all dependencies, remote data, and coverage
linux: py311-test-alldeps-cov
coverage: codecov
toxargs: -v
posargs: --remote-data=any
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up python ${{ matrix.python }} with tox environment ${{ matrix.tox_env }} on ${{ matrix.os }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}
- name: Install base dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
- name: Test with tox
run: |
tox -e ${{ matrix.tox_env }}
- name: Upload coverage to codecov
if: "contains(matrix.tox_env, '-cov')"
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
verbose: true
- name: (Allowed Failure) Python 3.12 on Linux with dev dependencies
linux: py312-test-devdeps
toxargs: -v
4 changes: 2 additions & 2 deletions .readthedocs.yml → .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: 2

build:
os: ubuntu-20.04
os: ubuntu-22.04
apt_packages:
- graphviz
tools:
python: "3.10"
python: "3.11"

sphinx:
builder: html
Expand Down
31 changes: 19 additions & 12 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,37 @@ New Features
^^^^^^^^^^^^

- Added 'interpolated_profile' option for HorneExtract. If The ``interpolated_profile`` option
is used, the image will be sampled in various wavelength bins (set by
``n_bins_interpolated_profile``), averaged in those bins, and samples are then
interpolated between (linear by default, interpolation degree can be set with
the ``interp_degree_interpolated_profile`` parameter) to generate a continuously varying
spatial profile that can be evaluated at any wavelength.[ #173]
is used, the image will be sampled in various wavelength bins (set by
``n_bins_interpolated_profile``), averaged in those bins, and samples are then
interpolated between (linear by default, interpolation degree can be set with
the ``interp_degree_interpolated_profile`` parameter) to generate a continuously varying
spatial profile that can be evaluated at any wavelength. [#173]

API Changes
^^^^^^^^^^^

- Fit residuals exposed for wavelength calibration in WavelengthCalibration1D.fit_residuals. [#446]
- Fit residuals exposed for wavelength calibration in ``WavelengthCalibration1D.fit_residuals``. [#446]

Bug Fixes
^^^^^^^^^

- Output 1D spectra from Background no longer include NaNs. Output 1D
spectra from BoxcarExtract no longer include NaNs when none are present
in the extraction window. NaNs in the window will still propagate to
BoxcarExtract's extracted 1D spectrum. [#159]
spectra from BoxcarExtract no longer include NaNs when none are present
in the extraction window. NaNs in the window will still propagate to
BoxcarExtract's extracted 1D spectrum. [#159]

- Backgrounds using median statistic properly ignore zero-weighted pixels
[#159]
- Backgrounds using median statistic properly ignore zero-weighted pixels.
[#159]

- HorneExtract now accepts 'None' as a vaild option for bkgrd_prof [#171]
- HorneExtract now accepts 'None' as a vaild option for ``bkgrd_prof``. [#171]

Other changes
^^^^^^^^^^^^^

- The following packages are now optional dependencies because they are not
required for core functionality: ``matplotlib``, ``photutils``, ``synphot``.
To install them anyway, use the ``[all]`` specifier when you install specreduce; e.g.:
``pip install specreduce[all]`` [#202]

1.3.0 (2022-12-05)
------------------
Expand Down
7 changes: 1 addition & 6 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
include README.rst
include CHANGES.rst
include setup.cfg
include LICENSE.rst
include pyproject.toml

recursive-include specreduce *.pyx *.c *.pxd
recursive-include docs *
recursive-include licenses *
recursive-include scripts *

prune notebook_sandbox
prune build
prune docs/_build
prune docs/api

global-exclude *.pyc *.o
21 changes: 13 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
Specreduce
==========

.. image:: https://github.com/astropy/specreduce/workflows/Python%20Tests/badge.svg
:target: https://github.com/astropy/specreduce/actions
.. image:: https://github.com/astropy/specreduce/actions/workflows/tox-tests.yml/badge.svg?branch=main
:target: https://github.com/astropy/specreduce/actions/workflows/tox-tests.yml
:alt: CI Status

.. image:: https://codecov.io/gh/astropy/specreduce/graph/badge.svg?token=3fLGjZ2Pe0
:target: https://codecov.io/gh/astropy/specreduce
:alt: Coverage

.. image:: https://readthedocs.org/projects/specreduce/badge/?version=latest
:target: http://specreduce.readthedocs.io/en/latest/?badge=latest
:target: http://specreduce.readthedocs.io/en/latest/
:alt: Documentation Status

.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.6608788.svg
:target: https://doi.org/10.5281/zenodo.6608788
:alt: Zenodo DOI 10.5281/zenodo.6608788
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.6608787.svg
:target: https://zenodo.org/doi/10.5281/zenodo.6608787
:alt: Zenodo DOI 10.5281/zenodo.6608787

.. image:: http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat
:target: http://www.astropy.org/
:target: http://www.astropy.org/
:alt: Powered by Astropy

Specreduce is an Astropy affiliated package with the goal of providing a shared
Specreduce is an Astropy coordinated package with the goal of providing a shared
set of Python utilities that can be used to reduce and calibrate spectroscopic data.

License
Expand Down
24 changes: 24 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Need to repeat the astropy header config here for tox."""

try:
from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS # noqa: E501
ASTROPY_HEADER = True
except ImportError:
ASTROPY_HEADER = False


def pytest_configure(config):

if ASTROPY_HEADER:

config.option.astropy_header = True

# Customize the following lines to add/remove entries from the list of
# packages for which version numbers are displayed when running the tests. # noqa: E501
PYTEST_HEADER_MODULES.pop('Pandas', None)
PYTEST_HEADER_MODULES['scikit-image'] = 'skimage'
PYTEST_HEADER_MODULES['photutils'] = 'photutils'
PYTEST_HEADER_MODULES['synphot'] = 'synphot'

from specreduce import __version__
TESTED_VERSIONS["specreduce"] = __version__
37 changes: 7 additions & 30 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,17 @@
# Thus, any C-extensions that are needed to build the documentation will *not*
# be accessible, and the documentation will not build correctly.

import os
import sys
import datetime
from importlib import import_module

from specreduce import __version__

try:
from sphinx_astropy.conf.v1 import * # noqa
except ImportError:
print('ERROR: the documentation requires the sphinx-astropy package to be installed')
sys.exit(1)

# Get configuration information from setup.cfg
from configparser import ConfigParser
conf = ConfigParser()

conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')])
setup_cfg = dict(conf.items('metadata'))

# -- General configuration ----------------------------------------------------

# By default, highlight as Python 3.
Expand All @@ -67,22 +60,19 @@
# -- Project information ------------------------------------------------------

# This does not *have* to match the package name, but typically does
project = setup_cfg['name']
author = setup_cfg['author']
project = "specreduce"
author = "Astropy Specreduce contributors"
copyright = '{0}, {1}'.format(
datetime.datetime.now().year, setup_cfg['author'])
datetime.datetime.now().year, author)

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.

import_module(setup_cfg['name'])
package = sys.modules[setup_cfg['name']]

# The short X.Y version.
version = package.__version__.split('-', 1)[0]
version = __version__.split('-', 1)[0]
# The full version, including alpha/beta/rc tags.
release = package.__version__
release = __version__


# -- Options for HTML output --------------------------------------------------
Expand Down Expand Up @@ -154,19 +144,6 @@

# -- Options for the edit_on_github extension ---------------------------------

if setup_cfg.get('edit_on_github').lower() == 'true':

extensions += ['sphinx_astropy.ext.edit_on_github']

edit_on_github_project = setup_cfg['github_project']
edit_on_github_branch = "main"

edit_on_github_source_root = ""
edit_on_github_doc_root = "docs"

# -- Resolving issue number to links in changelog -----------------------------
github_issues_url = 'https://github.com/{0}/issues/'.format(setup_cfg['github_project'])

# -- Turn on nitpicky mode for sphinx (to warn about references not found) ----
#
nitpicky = True
Expand Down
Loading

0 comments on commit 6b14578

Please sign in to comment.