diff --git a/.codecov.yaml b/.codecov.yaml index bd2cef304..8fe09b731 100644 --- a/.codecov.yaml +++ b/.codecov.yaml @@ -4,3 +4,8 @@ coverage: project: default: threshold: 0.2% + +codecov: + require_ci_to_pass: false + notify: + wait_for_ci: true diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 000000000..042a14edc --- /dev/null +++ b/.codespellrc @@ -0,0 +1,13 @@ +[codespell] +skip = *.asdf,*.fits,*.fts,*.header,*.json,*.xsh,*cache*,*egg*,*extern*,.git,.idea,.tox,_build,*truncated,*.svg,.asv_env,.history +ignore-words-list = + alog, + nd, + nin, + observ, + ot, + te, + upto, + afile, + precessed, + precess diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..a5de52d67 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,30 @@ +[run] +omit = + ndcube/conftest.py + ndcube/*setup_package* + ndcube/extern/* + ndcube/version* + */ndcube/conftest.py + */ndcube/*setup_package* + */ndcube/extern/* + */ndcube/version* + +[report] +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + # Don't complain about packages we have installed + except ImportError + # Don't complain if tests don't hit assertions + raise AssertionError + raise NotImplementedError + # Don't complain about script hooks + def main(.*): + # Ignore branches that don't pertain to this version of Python + pragma: py{ignore_python_version} + # Don't complain about IPython completion helper + def _ipython_key_completions_ + # typing.TYPE_CHECKING is False at runtime + if TYPE_CHECKING: + # Ignore typing overloads + @overload diff --git a/.cruft.json b/.cruft.json index 7299f184b..64ef33449 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { - "template": "/home/sam/Code/OpenAstronomy/../OpenAstronomy/packaging-guide", - "commit": "79c7c63fa9f20c7873063e08516778e99dd39318", + "template": "https://github.com/sunpy/package-template", + "commit": "6d6729b22066ef890e70c37438da70cac33e03b4", "checkout": null, "context": { "cookiecutter": { @@ -9,7 +9,7 @@ "short_description": "A package for multi-dimensional contiguous and non-contiguous coordinate aware arrays.", "author_name": "The SunPy Community", "author_email": "sunpy@googlegroups.com", - "project_url": "https://docs.sunpy.org/projects/ndcube/", + "project_url": "https://docs.sunpy.org/projects/ndcube", "license": "BSD 2-Clause", "minimum_python_version": "3.9", "use_compiled_extensions": "n", @@ -24,7 +24,7 @@ "docs/_static", ".github/workflows/sub_package_update.yml" ], - "_template": "/home/sam/Code/OpenAstronomy/../OpenAstronomy/packaging-guide" + "_template": "https://github.com/sunpy/package-template" } }, "directory": null diff --git a/.flake8 b/.flake8 index fcccaa10e..667c71300 100644 --- a/.flake8 +++ b/.flake8 @@ -22,6 +22,6 @@ exclude = __pycache__ docs/conf.py build - ndcube/__init__.py, + ndcube/__init__.py rst-directives = plot diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9fe37d50..5f6a6bf21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,6 +67,9 @@ jobs: submodules: false pytest: false toxdeps: tox-pypi-filter + libraries: | + apt: + - graphviz envs: | - linux: build_docs posargs: '' diff --git a/.github/workflows/sub_package_update.yml b/.github/workflows/sub_package_update.yml index 7f10d1bda..94a9e7e1a 100644 --- a/.github/workflows/sub_package_update.yml +++ b/.github/workflows/sub_package_update.yml @@ -1,16 +1,21 @@ -""" -This template is taken from the cruft example code, for further information please see: -https://cruft.github.io/cruft/#automating-updates-with-github-actions -""" +# This template is taken from the cruft example code, for further information please see: +# https://cruft.github.io/cruft/#automating-updates-with-github-actions name: Automatic Update from package template permissions: contents: write pull-requests: write on: - pull_request: - branches: - main + # Allow manual runs through the web UI + workflow_dispatch: + schedule: + # ┌───────── minute (0 - 59) + # │ ┌───────── hour (0 - 23) + # │ │ ┌───────── day of the month (1 - 31) + # │ │ │ ┌───────── month (1 - 12 or JAN-DEC) + # │ │ │ │ ┌───────── day of the week (0 - 6 or SUN-SAT) + - cron: '0 7 * * 1' # Every Monday at 7am UTC + jobs: update: runs-on: ubuntu-latest @@ -19,25 +24,25 @@ jobs: matrix: include: - add-paths: . - body: Use this to merge the changes to the repo + body: apply the changes to this repo. branch: cruft/update - commit-message: "Automate package template update" - title: Incoming updates from package template + commit-message: "Automatic package template update" + title: Updates from the package template - add-paths: .cruft.json - body: Use this to reject changes in the repo + body: reject these changes for this repo. branch: cruft/reject - commit-message: "Chore: reject this cruft update" + commit-message: "Reject this package template update" title: Reject new updates from package template steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.11" - name: Install Cruft - run: pip3 install cruft + run: python -m pip install cruft - name: Check if update is available continue-on-error: false @@ -57,15 +62,15 @@ jobs: - name: Run update if available if: steps.check.outputs.has_changes == '1' run: | - git config --global user.email "gromit@cruft.com" - git config --global user.name "Gromit" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + git config --global user.name "${{ github.actor }}" cruft update --skip-apply-ask --refresh-private-variables - git restore --staged + git restore --staged . - name: Create pull request - if: steps.check.output.has_changes == '1' - uses: peter-evans/create-pull-request@v4 + if: steps.check.outputs.has_changes == '1' + uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.GITHUB_TOKEN }} add-paths: ${{ matrix.add-paths }} @@ -75,5 +80,5 @@ jobs: branch-suffix: timestamp title: ${{ matrix.title }} body: | - This is an autogenerated PR. ${{ matrix.body }} - [Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template + This is an autogenerated PR, which will ${{ matrix.body }}. + [Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template diff --git a/.gitignore b/.gitignore index 4b2b58f09..5f2c3f600 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,8 @@ instance/ # Sphinx documentation docs/_build/ +# automodapi +docs/api # PyBuilder .pybuilder/ @@ -180,7 +182,7 @@ Icon # .nfs files are created when an open file is removed but is still being accessed .nfs* -### MacOS: https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore +# pytype static type analyzer .pytype/ # General @@ -237,8 +239,6 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk -### Extra Python Items and SunPy Specific - ### Extra Python Items and ndcube Specific .hypothesis .pytest_cache diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 000000000..507c4e705 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,16 @@ +[settings] +balanced_wrapping = true +skip = + docs/conf.py + ndcube/__init__.py +default_section = THIRDPARTY +include_trailing_comma = true +known_astropy = astropy, asdf +known_sunpy = sunpy +known_first_party = ndcube +length_sort = false +length_sort_sections = stdlib +line_length = 110 +multi_line_output = 3 +no_lines_before = LOCALFOLDER +sections = STDLIB, THIRDPARTY, ASTROPY, SUNPY, FIRSTPARTY, LOCALFOLDER diff --git a/.ruff.toml b/.ruff.toml index f9be9de96..cf615fba9 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -28,12 +28,16 @@ extend-ignore = [ # Part of configuration, not a package. "setup.py" = ["INP001"] "conftest.py" = ["INP001"] -# Implicit-namespace-package. The examples are not a package. -"docs/*.py" = ["INP001"] +"docs/conf.py" = [ + "E402" # Module imports not at top of file +] +"docs/*.py" = [ + "INP001", # Implicit-namespace-package. The examples are not a package. +] "__init__.py" = ["E402", "F401", "F403"] "test_*.py" = ["B011", "D", "E402", "PGH001", "S101"] # Need to import clients to register them, but don't use them in file "ndcube/net/__init__.py" = ["F811"] -[pydocstyle] +[lint.pydocstyle] convention = "numpy" diff --git a/licenses/TEMPLATE_LICENSE.rst b/licenses/TEMPLATE_LICENSE.rst index 9ac870dc3..544a2dba7 100644 --- a/licenses/TEMPLATE_LICENSE.rst +++ b/licenses/TEMPLATE_LICENSE.rst @@ -1,5 +1,5 @@ This project is based upon the OpenAstronomy package template -(https://github.com/open-astronomy/package-template/) which is licenced under the terms +(https://github.com/OpenAstronomy/package-template/) which is licensed under the terms of the following licence. --- diff --git a/pyproject.toml b/pyproject.toml index e285f213b..9d7f1759a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,8 +8,8 @@ build-backend = "setuptools.build_meta" [project] name = "ndcube" description = "A package for multi-dimensional contiguous and non-contiguous coordinate aware arrays." -readme = "README.rst" requires-python = ">=3.9" +readme = { file = "README.rst", content-type = "text/x-rst" } license = { file = "licenses/LICENSE.rst", content-type = "text/plain" } authors = [ { name = "The SunPy Community", email = "sunpy@googlegroups.com" }, @@ -19,18 +19,18 @@ dynamic = ["version"] [project.optional-dependencies] tests = [ - "pytest", - "pytest-doctestplus", - "pytest-cov", + "pytest", + "pytest-doctestplus", + "pytest-cov" ] docs = [ - "sphinx", - "sphinx-automodapi", + "sphinx", + "sphinx-automodapi", "tomli; python_version <\"3.11\"", ] [project.urls] -repository = "https://docs.sunpy.org/projects/ndcube/" +repository = "https://docs.sunpy.org/projects/ndcube" [tool.setuptools] zip-safe = false diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..a5e467af2 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,27 @@ +[pytest] +minversion = 7.0 +testpaths = + ndcube + docs +norecursedirs = + .tox + build + docs/_build + docs/generated + *.egg-info + examples + ndcube/_dev + .history + ndcube/extern +doctest_plus = enabled +doctest_optionflags = NORMALIZE_WHITESPACE FLOAT_CMP ELLIPSIS +text_file_format = rst +addopts = --doctest-rst -p no:unraisableexception -p no:threadexception +filterwarnings = + # Turn all warnings into errors so they do not pass silently. + error + # Do not fail on pytest config issues (i.e. missing plugins) but do show them + always::pytest.PytestConfigWarning + # A list of warnings to ignore follows. If you add to this list, you MUST + # add a comment or ideally a link to an issue that explains why the warning + # is being ignored diff --git a/setup.py b/setup.py new file mode 100755 index 000000000..c82334553 --- /dev/null +++ b/setup.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +from setuptools import setup + +setup() diff --git a/tox.ini b/tox.ini index 38d509080..2d32bc006 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,13 @@ [tox] min_version = 4.0 +requires = + tox-pypi-filter>=0.14 envlist = - py{39,310,311}{,-devdeps,-online,-figure,-conda,-oldestdeps} - build_docs + py{310,311,312} + py312-devdeps + py310-oldestdeps codestyle + build_docs [testenv] pypi_filter = https://raw.githubusercontent.com/sunpy/sunpy/main/.test_package_pins.txt @@ -15,10 +19,22 @@ allowlist_externals= changedir = .tmp/{envname} description = run tests + oldestdeps: with the oldest supported version of key dependencies devdeps: with the latest developer version of key dependencies online: that require remote data (as well as the offline ones) figure: runs the figure test suite. -setenv = + +pass_env = + # A variable to tell tests we are on a CI system + CI + # Custom compiler locations (such as ccache) + CC + # Location of locales (needed by sphinx on some systems) + LOCALE_ARCHIVE + # If the user has set a LC override we should follow it + LC_ALL + +set_env = MPLBACKEND = agg COLUMNS = 180 PYTEST_COMMAND = pytest -vvv -s -raR --pyargs ndcube --cov-report=xml --cov=ndcube --cov-config={toxinidir}/setup.cfg {toxinidir}/docs