From e326be6f534a6d8174bf19fe6c505ba1966d4c2f Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Tue, 18 Jun 2024 15:23:56 -0700 Subject: [PATCH] Apply template --- .codecov.yaml | 11 ++ .codespellrc | 13 ++ .coveragerc | 30 +++++ .cruft.json | 2 +- .flake8 | 27 ++++ .github/workflows/ci.yml | 102 +++++++++++++++ .github/workflows/sub_package_update.yml | 79 ++++++++++++ .gitignore | 151 +++++++++++++++++++--- .isort.cfg | 16 +++ .pre-commit-config.yaml | 50 ++++---- .readthedocs.yaml | 29 +++++ .readthedocs.yml | 23 ---- .rtd-environment.yml | 14 +-- .ruff.toml | 37 ++++++ .sunpy-template.yml | 12 -- .travis.yml | 153 ----------------------- LICENSE.rst | 2 +- MANIFEST.in | 20 ++- README.rst | 56 ++------- appveyor.yml | 50 -------- azure-pipelines.yml | 64 ---------- changelog/README.rst | 3 +- docs/conf.py | 110 ++++++---------- docs/index.rst | 17 ++- docs/make.bat | 70 +++++------ docs/whatsnew/changelog.rst | 6 +- licenses/LICENSE.rst | 2 +- licenses/TEMPLATE_LICENSE.rst | 6 +- pyproject.toml | 149 +++++++++++++++------- pytest.ini | 33 +++++ setup.cfg | 76 ----------- setup.py | 42 +------ sunkit_dem/__init__.py | 7 -- sunkit_dem/_dev/__init__.py | 6 + sunkit_dem/_dev/scm_version.py | 12 ++ sunkit_dem/_sunpy_init.py | 57 --------- sunkit_dem/base_model.py | 16 ++- sunkit_dem/conftest.py | 57 --------- sunkit_dem/model_factory.py | 2 +- sunkit_dem/tests/__init__.py | 1 - sunkit_dem/tests/coveragerc | 31 ----- sunkit_dem/tests/setup_package.py | 11 -- sunkit_dem/tests/test_util.py | 3 +- sunkit_dem/util.py | 5 +- sunkit_dem/version.py | 17 +++ tox.ini | 99 ++++++++------- 46 files changed, 865 insertions(+), 914 deletions(-) create mode 100644 .codecov.yaml create mode 100644 .codespellrc create mode 100644 .coveragerc create mode 100644 .flake8 create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/sub_package_update.yml create mode 100644 .isort.cfg create mode 100644 .readthedocs.yaml delete mode 100644 .readthedocs.yml create mode 100644 .ruff.toml delete mode 100644 .sunpy-template.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml delete mode 100644 azure-pipelines.yml create mode 100644 pytest.ini delete mode 100644 setup.cfg create mode 100644 sunkit_dem/_dev/__init__.py create mode 100644 sunkit_dem/_dev/scm_version.py delete mode 100644 sunkit_dem/_sunpy_init.py delete mode 100644 sunkit_dem/conftest.py delete mode 100644 sunkit_dem/tests/coveragerc delete mode 100644 sunkit_dem/tests/setup_package.py create mode 100644 sunkit_dem/version.py diff --git a/.codecov.yaml b/.codecov.yaml new file mode 100644 index 0000000..8fe09b7 --- /dev/null +++ b/.codecov.yaml @@ -0,0 +1,11 @@ +comment: off +coverage: + status: + 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 0000000..042a14e --- /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 0000000..00369a1 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,30 @@ +[run] +omit = + sunkit_dem/conftest.py + sunkit_dem/*setup_package* + sunkit_dem/extern/* + sunkit_dem/version* + */sunkit_dem/conftest.py + */sunkit_dem/*setup_package* + */sunkit_dem/extern/* + */sunkit_dem/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 09d6796..0f955d0 100644 --- a/.cruft.json +++ b/.cruft.json @@ -14,7 +14,7 @@ "minimum_python_version": "3.10", "use_compiled_extensions": "n", "enable_dynamic_dev_versions": "y", - "include_example_code": "y", + "include_example_code": "n", "include_cruft_update_github_workflow": "y", "_sphinx_theme": "alabaster", "_parent_project": "", diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..1a2c804 --- /dev/null +++ b/.flake8 @@ -0,0 +1,27 @@ +[flake8] +ignore = + # missing-whitespace-around-operator + E225 + # missing-whitespace-around-arithmetic-operator + E226 + # line-too-long + E501 + # unused-import + F401 + # undefined-local-with-import-star + F403 + # redefined-while-unused + F811 + # Line break occurred before a binary operator + W503, + # Line break occurred after a binary operator + W504 +max-line-length = 110 +exclude = + .git + __pycache__ + docs/conf.py + build + sunkit-dem/__init__.py +rst-directives = + plot diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9d2c1d5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,102 @@ + +name: CI + +on: + push: + branches: + - 'main' + - '*.*' + - '!*backport*' + tags: + - 'v*' + - '!*dev*' + - '!*pre*' + - '!*post*' + pull_request: + # Allow manual runs through the web UI + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + core: + uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main + with: + submodules: false + coverage: codecov + toxdeps: tox-pypi-filter + envs: | + - linux: py312 + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + sdist_verify: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - run: python -m pip install -U --user build + - run: python -m build . --sdist + - run: python -m pip install -U --user twine + - run: python -m twine check dist/* + + test: + needs: [core, sdist_verify] + uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main + with: + submodules: false + coverage: codecov + toxdeps: tox-pypi-filter + posargs: -n auto + envs: | + - windows: py311 + - macos: py310 + - linux: py310-oldestdeps + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + docs: + needs: [core] + uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main + with: + default_python: '3.10' + submodules: false + pytest: false + toxdeps: tox-pypi-filter + libraries: | + apt: + - graphviz + envs: | + - linux: build_docs + + cron: + if: | + github.event_name == 'workflow_dispatch' || ( + github.event_name == 'pull_request' && + contains(github.event.pull_request.labels.*.name, 'Run cron CI') + ) + uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main + with: + default_python: '3.10' + submodules: false + coverage: codecov + toxdeps: tox-pypi-filter + envs: | + - linux: py311-devdeps + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + +publish_pure: + needs: [test, docs] + uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@main + with: + python-version: '3.10' + test_extras: 'tests' + test_command: 'pytest -p no:warnings --doctest-rst --pyargs sunkit_dem' + submodules: false + secrets: + pypi_token: ${{ secrets.pypi_token }} diff --git a/.github/workflows/sub_package_update.yml b/.github/workflows/sub_package_update.yml new file mode 100644 index 0000000..0677948 --- /dev/null +++ b/.github/workflows/sub_package_update.yml @@ -0,0 +1,79 @@ +# 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: + # 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 + strategy: + fail-fast: true + matrix: + include: + - add-paths: . + body: apply the changes to this repo. + branch: cruft/update + commit-message: "Automatic package template update" + title: Updates from the package template + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install Cruft + run: python -m pip install git+/~https://github.com/Cadair/cruft@patch-p1 + + - name: Check if update is available + continue-on-error: false + id: check + run: | + CHANGES=0 + if [ -f .cruft.json ]; then + if ! cruft check; then + CHANGES=1 + fi + else + echo "No .cruft.json file" + fi + + echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT" + + - name: Run update if available + if: steps.check.outputs.has_changes == '1' + run: | + 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 . + + - name: Create pull request + if: steps.check.outputs.has_changes == '1' + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + add-paths: ${{ matrix.add-paths }} + commit-message: ${{ matrix.commit-message }} + branch: ${{ matrix.branch }} + delete-branch: true + branch-suffix: timestamp + title: ${{ matrix.title }} + body: | + 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 efe5584..3863428 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,17 @@ +### Python: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class +tmp/ # C extensions *.so # Distribution / packaging .Python +pip-wheel-metadata/ build/ develop-eggs/ dist/ @@ -20,13 +24,12 @@ parts/ sdist/ var/ wheels/ -pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST - +sunkit_dem/_version.py # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. @@ -71,6 +74,9 @@ instance/ # Sphinx documentation docs/_build/ +# automodapi +docs/api +docs/sg_execution_times.rst # PyBuilder .pybuilder/ @@ -95,7 +101,15 @@ ipython_config.py # install all needed dependencies. #Pipfile.lock -# PEP 582; used by e.g. github.com/David-OConnor/pyflow +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm __pypackages__/ # Celery stuff @@ -114,10 +128,6 @@ ENV/ env.bak/ venv.bak/ -# Spyder project settings -.spyderproject -.spyproject - # Rope project settings .ropeproject @@ -126,26 +136,127 @@ venv.bak/ # mypy .mypy_cache/ -.dmypy.json -dmypy.json # Pyre type checker .pyre/ +# IDE +# PyCharm +.idea + +# Spyder project settings +.spyderproject +.spyproject + +### VScode: https://raw.githubusercontent.com/github/gitignore/master/Global/VisualStudioCode.gitignore +.vscode/* +.vs/* + +### https://raw.github.com/github/gitignore/master/Global/OSX.gitignore +.DS_Store +.AppleDouble +.LSOverride + +# Icon must ends with two \r. +Icon + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +### Linux: https://raw.githubusercontent.com/github/gitignore/master/Global/Linux.gitignore +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + # pytype static type analyzer .pytype/ -# Cython debug symbols -cython_debug/ +# General +.DS_Store +.AppleDouble +.LSOverride -# static files generated from Django application using `collectstatic` -media -static +# Icon must end with two \r +Icon -# Specifc Template -docs/_build -docs/generated -docs/api + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Windows: https://raw.githubusercontent.com/github/gitignore/master/Global/Windows.gitignore + +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### Extra Python Items and SunPy Specific docs/whatsnew/latest_changelog.txt -sunkit_dem/version.py -htmlcov/ +examples/**/*.csv +figure_test_images* +tags +baseline + +# Release script +.github_cache + +# Misc Stuff +.history +*.orig +.tmp +node_modules/ +package-lock.json +package.json +.prettierrc + +# Log files generated by 'vagrant up' +*.log diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..a763356 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,16 @@ +[settings] +balanced_wrapping = true +skip = + docs/conf.py + sunkit_dem/__init__.py +default_section = THIRDPARTY +include_trailing_comma = true +known_astropy = astropy, asdf +known_sunpy = sunpy +known_first_party = sunkit_dem +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/.pre-commit-config.yaml b/.pre-commit-config.yaml index 064cec4..8934514 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,41 +1,35 @@ repos: - # The warnings/errors we check for here are: - # E101 - mix of tabs and spaces - # W191 - use of tabs - # W291 - trailing whitespace - # W292 - no newline at end of file - # W293 - trailing whitespace - # W391 - blank line at end of file - # E111 - 4 spaces per indentation level - # E112 - 4 spaces per indentation level - # E113 - 4 spaces per indentation level - # E303 - too many blank lines (3) - # E304 - blank lines found after function decorator - # E305 - expected 2 blank lines after class or function definition - # E306 - expected 1 blank line before a nested definition - # E502 - the backslash is redundant between brackets - # E722 - do not use bare except - # E901 - SyntaxError or IndentationError - # E902 - IOError - # F822: undefined name in __all__ - # F823: local variable name referenced before assignment - - repo: /~https://github.com/PyCQA/flake8 - rev: 7.1.0 + # This should be before any formatting hooks like isort + - repo: /~https://github.com/astral-sh/ruff-pre-commit + rev: "v0.4.8" hooks: - - id: flake8 - args: ['--count', '--select', 'E101,W191,W291,W292,W293,W391,E111,E112,E113,E303,E304,E306,E502,E722,E901,E902,F822,F823'] - + - id: ruff + args: ["--fix"] + - repo: /~https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort + exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|sunkit_dem/extern)$" - repo: /~https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: - id: check-ast - id: check-case-conflict - id: trailing-whitespace - exclude: ".*(.fits|.fts|.fit|.txt)$" + exclude: ".*(.fits|.fts|.fit|.header|.txt)$" - id: check-yaml - id: debug-statements - id: check-added-large-files + args: ["--enforce-all", "--maxkb=1054"] - id: end-of-file-fixer - exclude: ".*(.fits|.fts|.fit|.txt|tca.*)$" + exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|.json)$|^CITATION.rst$" - id: mixed-line-ending - exclude: ".*(.fits|.fts|.fit|.txt|tca.*)$" + exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*)$" + - repo: /~https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + args: [ "--write-changes" ] +ci: + autofix_prs: false + autoupdate_schedule: "quarterly" diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..790abab --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,29 @@ +version: 2 + +build: + os: ubuntu-22.04 + tools: + python: "mambaforge-4.10" + jobs: + post_checkout: + - git fetch --unshallow || true + pre_install: + - git update-index --assume-unchanged .rtd-environment.yml docs/conf.py + +conda: + environment: .rtd-environment.yml + +sphinx: + builder: html + configuration: docs/conf.py + fail_on_warning: false + +formats: + - htmlzip + +python: + install: + - method: pip + extra_requirements: + - docs + path: . diff --git a/.readthedocs.yml b/.readthedocs.yml deleted file mode 100644 index d0265f3..0000000 --- a/.readthedocs.yml +++ /dev/null @@ -1,23 +0,0 @@ -# .readthedocs.yml -# Read the Docs configuration file -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details - -# Required -version: 2 - -# Build documentation in the docs/ directory with Sphinx -sphinx: - configuration: docs/conf.py - -# Optionally build your docs in additional formats such as PDF and ePub -formats: [] - -# Optionally set the version of Python and requirements required to build your docs -python: - version: 3.7 - install: - - method: pip - path: . - extra_requirements: - - docs - - all diff --git a/.rtd-environment.yml b/.rtd-environment.yml index a214459..3c9d82e 100644 --- a/.rtd-environment.yml +++ b/.rtd-environment.yml @@ -1,13 +1,7 @@ name: sunkit-dem - channels: - - conda-forge - + - conda-forge dependencies: - - python>=3.7 - - sunpy - - Cython - - matplotlib - - numpy - - pip: - - sunpy-sphinx-theme + - python=3.12 + - pip + - graphviz!=2.42.*,!=2.43.* diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..a95d134 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,37 @@ +target-version = "py310" +line-length = 110 +exclude = [ + ".git,", + "__pycache__", + "build", + "sunkit-dem/version.py", +] + +[lint] +select = ["E", "F", "W", "UP", "PT"] +extend-ignore = [ + # pycodestyle (E, W) + "E501", # LineTooLong # TODO! fix + # pytest (PT) + "PT001", # Always use pytest.fixture() + "PT004", # Fixtures which don't return anything should have leading _ + "PT007", # Parametrize should be lists of tuples # TODO! fix + "PT011", # Too broad exception assert # TODO! fix + "PT023", # Always use () on pytest decorators +] + +[lint.per-file-ignores] +# Part of configuration, not a package. +"setup.py" = ["INP001"] +"conftest.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"] + +[lint.pydocstyle] +convention = "numpy" diff --git a/.sunpy-template.yml b/.sunpy-template.yml deleted file mode 100644 index d67667f..0000000 --- a/.sunpy-template.yml +++ /dev/null @@ -1,12 +0,0 @@ -default_context: - package_name: sunkit-dem - module_name: sunkit_dem - short_description: A package for computing solar differential emission measure distributions - author_name: SunPy Developers - author_email: - license: BSD 3-Clause - project_url: /~https://github.com/sunpy/sunkit-dem - github_repo: sunpy/sunkit-dem - minimum_python_version: 3.7 - use_compiled_extensions: n - include_example_code: n diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 46923b7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,153 +0,0 @@ -# We set the language to c because python isn't supported on the MacOS X nodes -# on Travis. However, the language ends up being irrelevant anyway, since we -# install Python ourselves using conda. -language: c - -os: - - linux - -# Setting sudo to false opts in to Travis-CI container-based builds. -sudo: false - -# The apt packages below are needed for sphinx builds. A full list of packages -# that can be included can be found here: -# -# /~https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise - -addons: - apt: - packages: - - graphviz - - texlive-latex-extra - - dvipng - -env: - global: - - # The following versions are the 'default' for tests, unless - # overridden underneath. They are defined here in order to save having - # to repeat them for all configurations. - - PYTHON_VERSION=3.7 - - NUMPY_VERSION=stable - - SUNPY_VERSION=stable - - MAIN_CMD='python setup.py' - - SETUP_CMD='test' - - EVENT_TYPE='pull_request push' - - - # List runtime dependencies for the package that are available as conda - # packages here. - - CONDA_DEPENDENCIES='' - - CONDA_DEPENDENCIES_DOC='sphinx-astropy' - - # List other runtime dependencies for the package that are available as - # pip packages here. - - PIP_DEPENDENCIES='' - - # Conda packages for affiliated packages are hosted in channel - # "astropy" while builds for astropy LTS with recent numpy versions - # are in astropy-ci-extras. If your package uses either of these, - # add the channels to CONDA_CHANNELS along with any other channels - # you want to use. - - CONDA_CHANNELS='astropy-ci-extras conda-forge' - - # If there are matplotlib or other GUI tests, uncomment the following - # line to use the X virtual framebuffer. - # - SETUP_XVFB=True - - # If you want to ignore certain flake8 errors, you can list them - # in FLAKE8_OPT, for example: - # - FLAKE8_OPT='--ignore=E501' - - FLAKE8_OPT='' - - matrix: - # Make sure that egg_info works without dependencies - - PYTHON_VERSION=3.7 SETUP_CMD='egg_info' - - -matrix: - - # Don't wait for allowed failures - fast_finish: true - - include: - # Try MacOS X - - os: osx - env: SETUP_CMD='test' - - # Do a coverage test. - - os: linux - env: SETUP_CMD='test --coverage' - - # Check for sphinx doc build warnings - we do this first because it - # may run for a long time - - os: linux - env: SETUP_CMD='build_docs -w' - CONDA_DEPENDENCIES=$CONDA_DEPENDENCIES_DOC - - # Now try Astropy dev with the latest Python and LTS with Python 2.7 and 3.x. - - os: linux - env: ASTROPY_VERSION=development - EVENT_TYPE='pull_request push cron' - - os: linux - env: ASTROPY_VERSION=lts - - # Try all python versions and Numpy versions. Since we can assume that - # the Numpy developers have taken care of testing Numpy with different - # versions of Python, we can vary Python and Numpy versions at the same - # time. - - - os: linux - env: PYTHON_VERSION=3.5 NUMPY_VERSION=1.12 - - os: linux - env: PYTHON_VERSION=3.6 NUMPY_VERSION=1.13 - - os: linux - env: NUMPY_VERSION=1.14 - - # Try numpy pre-release - - os: linux - env: NUMPY_VERSION=prerelease - EVENT_TYPE='pull_request push cron' - - # Do a PEP8 test with flake8 - - os: linux - env: MAIN_CMD='flake8 sunkit-dem --count --show-source --statistics $FLAKE8_OPT' SETUP_CMD='' - - allow_failures: - # Do a PEP8 test with flake8 - # (allow to fail unless your code completely compliant) - - os: linux - env: MAIN_CMD='flake8 sunkit-dem --count --show-source --statistics $FLAKE8_OPT' SETUP_CMD='' - -install: - - # We now use the ci-helpers package to set up our testing environment. - # This is done by using Miniconda and then using conda and pip to install - # dependencies. Which dependencies are installed using conda and pip is - # determined by the CONDA_DEPENDENCIES and PIP_DEPENDENCIES variables, - # which should be space-delimited lists of package names. See the README - # in /~https://github.com/astropy/ci-helpers for information about the full - # list of environment variables that can be used to customize your - # environment. In some cases, ci-helpers may not offer enough flexibility - # in how to install a package, in which case you can have additional - # commands in the install: section below. - - - git clone --depth 1 git://github.com/astropy/ci-helpers.git - - source ci-helpers/travis/setup_conda.sh - - # As described above, using ci-helpers, you should be able to set up an - # environment with dependencies installed using conda and pip, but in some - # cases this may not provide enough flexibility in how to install a - # specific dependency (and it will not be able to install non-Python - # dependencies). Therefore, you can also include commands below (as - # well as at the start of the install section or in the before_install - # section if they are needed before setting up conda) to install any - # other dependencies. - -script: - - $MAIN_CMD $SETUP_CMD - -after_success: - # If coveralls.io is set up for this package, uncomment the line below. - # The coveragerc file may be customized as needed for your package. - # - if [[ $SETUP_CMD == *coverage* ]]; then coveralls --rcfile='sunkit-dem/tests/coveragerc'; fi diff --git a/LICENSE.rst b/LICENSE.rst index 6f9216f..2c76e61 100644 --- a/LICENSE.rst +++ b/LICENSE.rst @@ -1,4 +1,4 @@ -Copyright (c) 2020, SunPy Developers +Copyright (c) 2020-2024, SunPy Developers All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/MANIFEST.in b/MANIFEST.in index 4723376..ce80eb3 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,17 +1,11 @@ -include README.rst -include CHANGES.rst -include setup.cfg -include LICENSE.rst -include pyproject.toml - -recursive-include sunkit_dem *.pyx *.c *.pxd -recursive-include docs * -recursive-include licenses * -recursive-include cextern * -recursive-include scripts * - +# Exclude specific files +# All files which are tracked by git and not explicitly excluded here are included by setuptools_scm +# Prune folders prune build prune docs/_build prune docs/api - global-exclude *.pyc *.o + +# This subpackage is only used in development checkouts +# and should not be included in built tarballs +prune sunkit_dem/_dev diff --git a/README.rst b/README.rst index 8500db2..61d0178 100644 --- a/README.rst +++ b/README.rst @@ -1,43 +1,26 @@ -Sunkit-Dem -========== +************** +``sunkit-Dem`` +************** -|SunPy Badge| |matrix| +A package for computing differential emission measures using multiple methods with a common API. -.. |SunPy Badge| image:: http://img.shields.io/badge/powered%20by-SunPy-orange.svg?style=flat - :target: http://www.sunpy.org - :alt: Powered by SunPy Badge -.. |matrix| image:: https://img.shields.io/matrix/sunpy:openastronomy.org.svg?colorB=%23FE7900&label=Chat&logo=matrix&server_fqdn=openastronomy.modular.im - :target: https://riot.im/app/#/room/#sunkit-dem:openastronomy.org - -Sunkit-Dem is an open-source package for computing solar differential emission measure distributions. - -Installation -============ - -If you want to help develop sunkit-image, or just want to try out the package, you will need to install it from GitHub. -The best way to do this is to create a new python virtual environment (either with ``pipenv`` or ``conda``). -Once you have that virtual environment: - -.. code:: bash - - $ git clone /~https://github.com/sunpy/sunkit-image.git - $ cd sunkit-dem - $ pip install -e . +License +------- -For detailed (general) installation instructions, see the `installation guide`_ in the SunPy docs. +This project is Copyright (c) SunPy Developers and licensed under +the terms of the BSD 3-Clause license. This package is based upon +the `Openastronomy packaging guide `_ +which is licensed under the BSD 3-clause licence. See the licenses folder for +more information. Contributing -============ +------------ We love contributions! sunkit-dem is open source, built on open source, and we'd love to have you hang out in our community. -Head over to our chat room `#sunkit-dem:openastronomy.org`_ if you want to -let us know what you like to work on, or if you have any questions. -You can also check out the `issues page`_ for the list of known outstanding items. -**Imposter syndrome disclaimer**: +**Imposter syndrome disclaimer**: We want your help. No, really. -We want your help. No, really. There may be a little voice inside your head that is telling you that you're not ready to be an open source contributor; that your skills aren't nearly good enough to contribute. What could you possibly offer a project like this one? @@ -61,16 +44,3 @@ Note: This disclaimer was originally written by `PyCon talk `_, and was adapted by sunkit-dem based on its use in the README file for the `MetPy project `_. - -License -======= - -This project is Copyright (c) SunPy Developers and licensed under -the terms of the BSD 3-Clause license. This package is based upon -the `Openastronomy packaging guide `_ -which is licensed under the BSD 3-clause licence. See the licenses folder for -more information. - -.. _installation guide: https://docs.sunpy.org/en/stable/guide/installation/index.html -.. _`#sunkit-dem:openastronomy.org`: https://riot.im/app/#/room/#sunkit-dem:openastronomy.org -.. _issues page: /~https://github.com/sunpy/sunkit-dem/issues diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 53cafb0..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,50 +0,0 @@ -# AppVeyor.com is a Continuous Integration service to build and run tests under -# Windows - -environment: - - global: - PYTHON: "C:\\conda" - MINICONDA_VERSION: "latest" - CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci-helpers\\appveyor\\windows_sdk.cmd" - PYTHON_ARCH: "64" # needs to be set for CMD_IN_ENV to succeed. If a mix - # of 32 bit and 64 bit builds are needed, move this - # to the matrix section. - - - # List runtime dependencies for the package that are available as conda - # packages here. - CONDA_DEPENDENCIES: "" - - # List other runtime dependencies for the package that are available as - # pip packages here. - PIP_DEPENDENCIES: "" - - # Conda packages for affiliated packages are hosted in channel - # "astropy" while builds for astropy LTS with recent numpy versions - # are in astropy-ci-extras. If your package uses either of these, - # add the channels to CONDA_CHANNELS along with any other channels - # you want to use. - CONDA_CHANNELS: "astropy-ci-extras astropy" - - matrix: - - # We test Python 3.7 for Python 3 support. - - PYTHON_VERSION: "3.7" - ASTROPY_VERSION: "stable" - NUMPY_VERSION: "stable" - -platform: - -x64 - -install: - - "git clone --depth 1 git://github.com/astropy/ci-helpers.git" - - "powershell ci-helpers/appveyor/install-miniconda.ps1" - - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" - - "activate test" - -# Not a .NET project, we build the package in the install step instead -build: false - -test_script: - - "%CMD_IN_ENV% python setup.py test" diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index d6fd19d..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: $(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.rr) -variables: - CI_NAME: Azure Pipelines - CI_BUILD_ID: $(Build.BuildId) - CI_BUILD_URL: "https://dev.azure.com/sunpy/sunkit-dem/_build/results?buildId=$(Build.BuildId)" - CIBW_BUILD: cp37-* cp38-* - CIBW_SKIP: "*-win32 *-manylinux1_i686" - -resources: - repositories: - - repository: OpenAstronomy - type: github - endpoint: sunpy - name: OpenAstronomy/azure-pipelines-templates - ref: master - -trigger: - branches: - include: - - '*' - exclude: - - '*backport*' - tags: - include: - - 'v*' - exclude: - - '*dev*' - - '*pre*' - - '*post*' - -jobs: -- template: run-tox-env.yml@OpenAstronomy - parameters: - submodules: false - coverage: codecov - envs: - - windows: py37 - name: py37_test - - - linux: py38 - name: py38_test - - - linux: codestyle - name: codestyle - - -# On branches which aren't master, and not Pull Requests, build the wheels but only upload them on tags -- ${{ if and(ne(variables['Build.Reason'], 'PullRequest'), not(contains(variables['Build.SourceBranch'], 'master'))) }}: - - template: publish.yml@OpenAstronomy - parameters: - # Only Upload to PyPI on tags - ${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}: - pypi_connection_name : 'PyPI' - - test_extras: 'test' - test_command: 'pytest -p no:warnings --doctest-rst -m "not figure" --pyargs sunkit_dem' - submodules: false - targets: - - wheels_linux - - wheels_macos - - sdist - dependsOn: - - py37_test - - py38_test diff --git a/changelog/README.rst b/changelog/README.rst index f8ba2f2..7d388e3 100644 --- a/changelog/README.rst +++ b/changelog/README.rst @@ -22,7 +22,8 @@ Each file should be named like ``.[.].rst``, where * ``feature``: New user facing features and any new behavior. * ``bugfix``: Fixes a reported bug. * ``doc``: Documentation addition or improvement, like rewording an entire session or adding missing docs. -* ``removal``: Feature deprecation and/or feature removal. +* ``deprecation``: Feature deprecation +* ``removal``: Feature removal. * ``trivial``: A change which has no user facing effect or is tiny change. So for example: ``123.feature.rst``, ``456.bugfix.rst``. diff --git a/docs/conf.py b/docs/conf.py index 4cab3ee..239035f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,115 +1,83 @@ -# -*- coding: utf-8 -*- -# # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config +import datetime # -- Project information ----------------------------------------------------- -project = 'sunkit-dem' -copyright = '2019-2020, SunPy Developers' -author = 'SunPy Developers' - # The full version, including alpha/beta/rc tags from sunkit_dem import __version__ + release = __version__ -is_development = '.dev' in __version__ + +project = "sunkit-dem" +author = "SunPy Developers" +copyright = f"{datetime.datetime.now().year}, {author}" # noqa: A001 # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# extensions coming with Sphinx (named "sphinx.ext.*") or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.inheritance_diagram', - 'sphinx.ext.viewcode', - 'sphinx.ext.napoleon', - 'sphinx.ext.doctest', - 'sphinx.ext.mathjax', - 'sphinx_automodapi.automodapi', - 'sphinx_automodapi.smart_resolver', + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", + "sphinx.ext.todo", + "sphinx.ext.coverage", + "sphinx.ext.inheritance_diagram", + "sphinx.ext.viewcode", + "sphinx.ext.napoleon", + "sphinx.ext.doctest", + "sphinx.ext.mathjax", + "sphinx_automodapi.automodapi", + "sphinx_automodapi.smart_resolver", + "sphinx_changelog", ] # Add any paths that contain templates here, relative to this directory. -# templates_path = ['_templates'] +# templates_path = ["_templates"] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" -# The reST default role (used for this markup: `text`) to use for all -# documents. Set to the "smart" one. -default_role = 'obj' +# Treat everything in single ` as a Python reference. +default_role = 'py:obj' # -- Options for intersphinx extension --------------------------------------- # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - 'python': ('https://docs.python.org/3/', - (None, 'http://data.astropy.org/intersphinx/python3.inv')), - 'numpy': ('https://docs.scipy.org/doc/numpy/', - (None, 'http://data.astropy.org/intersphinx/numpy.inv')), - 'scipy': ('https://docs.scipy.org/doc/scipy/reference/', - (None, 'http://data.astropy.org/intersphinx/scipy.inv')), - 'matplotlib': ('https://matplotlib.org/', - (None, 'http://data.astropy.org/intersphinx/matplotlib.inv')), - 'astropy': ('http://docs.astropy.org/en/stable/', None), - 'sunpy': ('https://docs.sunpy.org/en/stable/', None), - 'ndcube':('https://docs.sunpy.org/projects/ndcube/en/stable/', None)} +intersphinx_mapping = {"python": ("https://docs.python.org/", None)} # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. - -try: - from sunpy_sphinx_theme.conf import * -except ImportError: - html_theme = 'default' - +html_theme = "sunpy" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -# html_static_path = ['_static'] - -# Render inheritance diagrams in SVG -graphviz_output_format = "svg" - -graphviz_dot_args = [ - '-Nfontsize=10', - '-Nfontname=Helvetica Neue, Helvetica, Arial, sans-serif', - '-Efontsize=10', - '-Efontname=Helvetica Neue, Helvetica, Arial, sans-serif', - '-Gfontsize=10', - '-Gfontname=Helvetica Neue, Helvetica, Arial, sans-serif' -] - - -""" -Write the latest changelog into the documentation. -""" -target_file = os.path.abspath("./whatsnew/latest_changelog.txt") -try: - from sunpy.util.towncrier import generate_changelog_for_docs - if is_development: - generate_changelog_for_docs("../", target_file) -except Exception as e: - print(f"Failed to add changelog to docs with error {e}.") -# Make sure the file exists or else sphinx will complain. -open(target_file, 'a').close() +# html_static_path = ["_static"] + +# By default, when rendering docstrings for classes, sphinx.ext.autodoc will +# make docs with the class-level docstring and the class-method docstrings, +# but not the __init__ docstring, which often contains the parameters to +# class constructors across the scientific Python ecosystem. The option below +# will append the __init__ docstring to the class-level docstring when rendering +# the docs. For more options, see: +# https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autoclass_content +autoclass_content = "both" + +# -- Other options ---------------------------------------------------------- diff --git a/docs/index.rst b/docs/index.rst index 3409fe9..77eb3f3 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,5 +1,6 @@ +************************ sunkit-dem Documentation ------------------------- +************************ This is the documentation for sunkit-dem. @@ -7,9 +8,17 @@ This is the documentation for sunkit-dem. :maxdepth: 2 whatsnew/index + reference +Installation +============ -Reference/API -============= +If you want to help develop sunkit-image, or just want to try out the package, you will need to install it from GitHub for the time being. +The best way to do this is to create a new python virtual environment (either with ``pipenv`` or ``conda``). +Once you have that virtual environment: -.. automodapi:: sunkit-dem +.. code:: bash + + $ git clone /~https://github.com/sunpy/sunkit-image.git + $ cd sunkit-dem + $ pip install -e . diff --git a/docs/make.bat b/docs/make.bat index 922152e..2119f51 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -1,35 +1,35 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=. -set BUILDDIR=_build - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/whatsnew/changelog.rst b/docs/whatsnew/changelog.rst index 37943cf..a3678c4 100644 --- a/docs/whatsnew/changelog.rst +++ b/docs/whatsnew/changelog.rst @@ -4,5 +4,7 @@ Full Changelog ************** -.. include:: latest_changelog.txt -.. include:: ../../CHANGELOG.rst +.. changelog:: + :towncrier: ../../ + :towncrier-skip-if-empty: + :changelog_file: ../../CHANGELOG.rst diff --git a/licenses/LICENSE.rst b/licenses/LICENSE.rst index 7af7784..c44870c 100644 --- a/licenses/LICENSE.rst +++ b/licenses/LICENSE.rst @@ -1,4 +1,4 @@ -Copyright (c) 2019, SunPy Developers +Copyright (c) 2024, SunPy Developers All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/licenses/TEMPLATE_LICENSE.rst b/licenses/TEMPLATE_LICENSE.rst index f29177b..544a2db 100644 --- a/licenses/TEMPLATE_LICENSE.rst +++ b/licenses/TEMPLATE_LICENSE.rst @@ -1,10 +1,10 @@ -This project is based upon the Astropy package template -(/~https://github.com/astropy/package-template/) which is licenced under the terms +This project is based upon the OpenAstronomy package template +(/~https://github.com/OpenAstronomy/package-template/) which is licensed under the terms of the following licence. --- -Copyright (c) 2018, Astropy Developers +Copyright (c) 2018, OpenAstronomy Developers All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/pyproject.toml b/pyproject.toml index 77c8715..02f60aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,48 +1,111 @@ [build-system] +requires = [ + "setuptools>=62.1", + "setuptools_scm[toml]>=6.2", + "wheel",] +build-backend = "setuptools.build_meta" -requires = ["setuptools", - "setuptools_scm", - "wheel"] +[project] +name = "sunkit_dem" +description = "A package for computing differential emission measures using multiple methods with a common API" +requires-python = ">=3.10" +readme = { file = "README.rst", content-type = "text/x-rst" } +license = { file = "licenses/LICENSE.rst", content-type = "text/plain" } +authors = [ + { name = "SunPy Developers", email = "sunpy@googlegroups.com" }, +] +dependencies = [ + "ndcube", + "sunpy", +] +dynamic = ["version"] -build-backend = 'setuptools.build_meta' +[project.scripts] +open_astronomy_package_template_example = "sunkit_dem.example_mod:main" +[project.optional-dependencies] +tests = [ + "pytest", + "pytest-astropy", + "pytest-xdist", +] +docs = [ + "sphinx", + "sphinx-automodapi", + "towncrier", + "sunpy-sphinx-theme", + "sphinx-changelog", +] +[project.urls] +repository = "/~https://github.com/sunpy/sunkit-dem" + +[tool.setuptools] +zip-safe = false +include-package-data = true + +[tool.setuptools.packages.find] +exclude = ["sunkit_dem._dev*"] + +[tool.setuptools_scm] +write_to = "sunkit_dem/_version.py" + +[tool.gilesbot] + + [tool.gilesbot.pull_requests] + enabled = true + + [tool.gilesbot.towncrier_changelog] + enabled = true + verify_pr_number = true + changelog_skip_label = "No Changelog Entry Needed" + help_url = "/~https://github.com/sunpy/sunkit-dem/blob/main/changelog/README.rst" + + changelog_missing_long = "There isn't a changelog file in this pull request. Please add a changelog file to the `changelog/` directory following the instructions in the changelog [README](/~https://github.com/sunpy/sunkit-dem/blob/main/changelog/README.rst)." + + type_incorrect_long = "The changelog file you added is not one of the allowed types. Please use one of the types described in the changelog [README](/~https://github.com/sunpy/sunkit-dem/blob/main/changelog/README.rst)" + + number_incorrect_long = "The number in the changelog file you added does not match the number of this pull request. Please rename the file." + +# TODO: This should be in towncrier.toml but Giles currently only works looks in +# pyproject.toml we should move this back when it's fixed. [tool.towncrier] - package = "sunkit-dem" - filename = "CHANGELOG.rst" - directory = "changelog/" - issue_format = "`#{issue} `__" - - [[tool.towncrier.type]] - directory = "breaking" - name = "Backwards Incompatible Changes" - showcontent = true - - [[tool.towncrier.type]] - directory = "api" - name = "API Changes" - showcontent = true - - [[tool.towncrier.type]] - directory = "removal" - name = "Deprecations and Removals" - showcontent = true - - [[tool.towncrier.type]] - directory = "feature" - name = "Features" - showcontent = true - - [[tool.towncrier.type]] - directory = "bugfix" - name = "Bug Fixes" - showcontent = true - - [[tool.towncrier.type]] - directory = "doc" - name = "Improved Documentation" - showcontent = true - - [[tool.towncrier.type]] - directory = "trivial" - name = "Trivial/Internal Changes" - showcontent = true + package = "sunkit-dem" + filename = "CHANGELOG.rst" + directory = "changelog/" + issue_format = "`#{issue} `__" + title_format = "{version} ({project_date})" + + [[tool.towncrier.type]] + directory = "breaking" + name = "Breaking Changes" + showcontent = true + + [[tool.towncrier.type]] + directory = "deprecation" + name = "Deprecations" + showcontent = true + + [[tool.towncrier.type]] + directory = "removal" + name = "Removals" + showcontent = true + + [[tool.towncrier.type]] + directory = "feature" + name = "New Features" + showcontent = true + + [[tool.towncrier.type]] + directory = "bugfix" + name = "Bug Fixes" + showcontent = true + + [[tool.towncrier.type]] + directory = "doc" + name = "Documentation" + showcontent = true + + [[tool.towncrier.type]] + directory = "trivial" + name = "Internal Changes" + showcontent = true diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..7f5398d --- /dev/null +++ b/pytest.ini @@ -0,0 +1,33 @@ +[pytest] +minversion = 7.0 +testpaths = + sunkit_dem + docs +norecursedirs = + .tox + build + docs/_build + docs/generated + *.egg-info + examples + sunkit_dem/_dev + .history + sunkit_dem/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.cfg b/setup.cfg deleted file mode 100644 index a9c4c4c..0000000 --- a/setup.cfg +++ /dev/null @@ -1,76 +0,0 @@ -[metadata] -name = sunkit_dem -author = SunPy Developers -author_email = will.t.barnes@gmail.com -license = BSD 3-Clause -license_file = LICENSE.rst -url = /~https://github.com/sunpy/sunkit-dem -description = A package for computing solar differential emission measure distributions -long_description = file: README.rst - -[options] -zip_safe = False -packages = find: -python_requires = >=3.7 -setup_requires = setuptools_scm -install_requires = - sunpy - ndcube - - - -[options.extras_require] -test = - pytest - pytest-astropy - pytest-cov -docs = - sphinx - sphinx-automodapi - towncrier - - sunpy-sphinx-theme - - -[options.package_data] -sunkit_dem = data/* - -[tool:pytest] -testpaths = "sunkit_dem" "docs" -doctest_plus = enabled -text_file_format = rst -addopts = --doctest-rst -remote_data_strict = True - -[coverage:run] -omit = - sunkit_dem/_sunpy_init* - sunkit_dem/conftest.py - sunkit_dem/*setup_package* - sunkit_dem/tests/* - sunkit_dem/*/tests/* - sunkit_dem/extern/* - sunkit_dem/version* - */sunkit_dem/_sunpy_init* - */sunkit_dem/conftest.py - */sunkit_dem/*setup_package* - */sunkit_dem/tests/* - */sunkit_dem/*/tests/* - */sunkit_dem/extern/* - */sunkit_dem/version* - -[coverage: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_ diff --git a/setup.py b/setup.py index 7818b38..c823345 100755 --- a/setup.py +++ b/setup.py @@ -1,44 +1,4 @@ #!/usr/bin/env python -# Licensed under a 3-clause BSD style license - see LICENSE.rst - -import os -from itertools import chain - from setuptools import setup -from setuptools.config import read_configuration - -################################################################################ -# Programmatically generate some extras combos. -################################################################################ -extras = read_configuration("setup.cfg")['options']['extras_require'] - -# Dev is everything -extras['dev'] = list(chain(*extras.values())) - -# All is everything but tests and docs -exclude_keys = ("tests", "docs", "dev") -ex_extras = dict(filter(lambda i: i[0] not in exclude_keys, extras.items())) -# Concatenate all the values together for 'all' -extras['all'] = list(chain.from_iterable(ex_extras.values())) - -################################################################################ -# Version configuration and setup call -################################################################################ - -VERSION_TEMPLATE = """ -# Note that we need to fall back to the hard-coded version if either -# setuptools_scm can't be imported or setuptools_scm can't determine the -# version, so we catch the generic 'Exception'. -try: - from setuptools_scm import get_version - __version__ = get_version(root='..', relative_to=__file__) -except Exception: - __version__ = '{version}' -""".lstrip() - -setup( - extras_require=extras, - use_scm_version={'write_to': os.path.join('sunkit_dem', 'version.py'), - 'write_to_template': VERSION_TEMPLATE}, -) +setup() diff --git a/sunkit_dem/__init__.py b/sunkit_dem/__init__.py index c52e7d8..7556cf1 100644 --- a/sunkit_dem/__init__.py +++ b/sunkit_dem/__init__.py @@ -1,9 +1,2 @@ -# Licensed under a 3-clause BSD style license - see LICENSE.rst - -try: - from .version import __version__ -except ImportError: - __version__ = "unknown" - from .base_model import * from .model_factory import * diff --git a/sunkit_dem/_dev/__init__.py b/sunkit_dem/_dev/__init__.py new file mode 100644 index 0000000..72583c0 --- /dev/null +++ b/sunkit_dem/_dev/__init__.py @@ -0,0 +1,6 @@ +""" +This package contains utilities that are only used when developing drms in a +copy of the source repository. +These files are not installed, and should not be assumed to exist at +runtime. +""" diff --git a/sunkit_dem/_dev/scm_version.py b/sunkit_dem/_dev/scm_version.py new file mode 100644 index 0000000..1bcf0dd --- /dev/null +++ b/sunkit_dem/_dev/scm_version.py @@ -0,0 +1,12 @@ +# Try to use setuptools_scm to get the current version; this is only used +# in development installations from the git repository. +import os.path + +try: + from setuptools_scm import get_version + + version = get_version(root=os.path.join('..', '..'), relative_to=__file__) +except ImportError: + raise +except Exception as e: + raise ValueError('setuptools_scm can not determine version.') from e diff --git a/sunkit_dem/_sunpy_init.py b/sunkit_dem/_sunpy_init.py deleted file mode 100644 index 7b31761..0000000 --- a/sunkit_dem/_sunpy_init.py +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed under a 3-clause BSD style license - see LICENSE.rst - -__all__ = ['__version__', '__githash__'] - -# this indicates whether or not we are in the package's setup.py -try: - _ASTROPY_SETUP_ -except NameError: - - import builtins - builtins._ASTROPY_SETUP_ = False - -try: - from .version import version as __version__ -except ImportError: - __version__ = '' -try: - from .version import githash as __githash__ -except ImportError: - __githash__ = '' - - -if not _ASTROPY_SETUP_: # noqa - import os - from warnings import warn - from astropy.config.configuration import ( - update_default_config, - ConfigurationDefaultMissingError, - ConfigurationDefaultMissingWarning) - - # Create the test function for self test - from astropy.tests.runner import TestRunner - test = TestRunner.make_test_runner_in(os.path.dirname(__file__)) - test.__test__ = False - __all__ += ['test'] - - # add these here so we only need to cleanup the namespace at the end - config_dir = None - - if not os.environ.get('ASTROPY_SKIP_CONFIG_UPDATE', False): - config_dir = os.path.dirname(__file__) - config_template = os.path.join(config_dir, __package__ + ".cfg") - if os.path.isfile(config_template): - try: - update_default_config( - __package__, config_dir, version=__version__) - except TypeError as orig_error: - try: - update_default_config(__package__, config_dir) - except ConfigurationDefaultMissingError as e: - wmsg = (e.args[0] + - " Cannot install default profile. If you are " - "importing from source, this is expected.") - warn(ConfigurationDefaultMissingWarning(wmsg)) - del e - except Exception: - raise orig_error diff --git a/sunkit_dem/base_model.py b/sunkit_dem/base_model.py index 2e84b15..8832b96 100644 --- a/sunkit_dem/base_model.py +++ b/sunkit_dem/base_model.py @@ -1,17 +1,16 @@ """ Base model class for DEM models """ -from abc import ABC, abstractmethod, abstractclassmethod -import copy +from abc import ABC, abstractmethod -import numpy as np -from astropy.nddata import StdDevUncertainty -import astropy.units as u -import astropy.wcs import ndcube -from ndcube.extra_coords.table_coord import QuantityTableCoordinate, MultipleTableCoordinate +import numpy as np +from ndcube.extra_coords.table_coord import MultipleTableCoordinate, QuantityTableCoordinate from ndcube.wcs.wrappers import CompoundLowLevelWCS +import astropy.units as u +from astropy.nddata import StdDevUncertainty + __all__ = ["GenericModel"] @@ -21,7 +20,6 @@ class BaseModel(ABC): def _model(self): raise NotImplementedError - @abstractclassmethod def defines_model_for(self): raise NotImplementedError @@ -113,7 +111,7 @@ def kernel_matrix(self): return np.stack([self.kernel[k] for k in self._keys]) def fit(self, *args, **kwargs): - """ + r""" Apply inversion procedure to data. Returns diff --git a/sunkit_dem/conftest.py b/sunkit_dem/conftest.py deleted file mode 100644 index ebab8a1..0000000 --- a/sunkit_dem/conftest.py +++ /dev/null @@ -1,57 +0,0 @@ -# This file is used to configure the behavior of pytest when using the Astropy -# test infrastructure. - -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 astropy.tests.plugins.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. For Astropy v2.0 or later, there are 2 additional keywords, -## as follow (although default should work for most cases). -## To ignore some packages that produce deprecation warnings on import -## (in addition to 'compiler', 'scipy', 'pygments', 'ipykernel', and -## 'setuptools'), add: -## modules_to_ignore_on_import=['module_1', 'module_2'] -## To ignore some specific deprecation warning messages for Python version -## MAJOR.MINOR or later, add: -## warnings_to_ignore_by_pyver={(MAJOR, MINOR): ['Message to ignore']} -# 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['scikit-image'] = 'skimage' -# del PYTEST_HEADER_MODULES['h5py'] -# 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 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/sunkit_dem/model_factory.py b/sunkit_dem/model_factory.py index a347dca..773f36d 100644 --- a/sunkit_dem/model_factory.py +++ b/sunkit_dem/model_factory.py @@ -16,7 +16,7 @@ def __call__(self, *args, **kwargs): for key in self.registry: if self.registry[key](*args, **kwargs): WidgetType = key - # If no matches, return the defualt model + # If no matches, return the default model WidgetType = self.default_widget_type if WidgetType is None else WidgetType return WidgetType(*args, **kwargs) diff --git a/sunkit_dem/tests/__init__.py b/sunkit_dem/tests/__init__.py index 838b457..92ea707 100644 --- a/sunkit_dem/tests/__init__.py +++ b/sunkit_dem/tests/__init__.py @@ -1,4 +1,3 @@ -# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This module contains package tests. """ diff --git a/sunkit_dem/tests/coveragerc b/sunkit_dem/tests/coveragerc deleted file mode 100644 index faa58d2..0000000 --- a/sunkit_dem/tests/coveragerc +++ /dev/null @@ -1,31 +0,0 @@ -[run] -source = {packagename} -omit = - {packagename}/_sunpy_init* - {packagename}/conftest* - {packagename}/cython_version* - {packagename}/setup_package* - {packagename}/*/setup_package* - {packagename}/*/*/setup_package* - {packagename}/tests/* - {packagename}/*/tests/* - {packagename}/*/*/tests/* - {packagename}/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} diff --git a/sunkit_dem/tests/setup_package.py b/sunkit_dem/tests/setup_package.py deleted file mode 100644 index 118325c..0000000 --- a/sunkit_dem/tests/setup_package.py +++ /dev/null @@ -1,11 +0,0 @@ -# import os - -# If this package has tests data in the tests/data directory, add them to -# the paths here, see commented example -paths = ['coveragerc', -# os.path.join('data', '*fits') - ] - -def get_package_data(): - return { - _ASTROPY_PACKAGE_NAME_ + '.tests': paths} diff --git a/sunkit_dem/tests/test_util.py b/sunkit_dem/tests/test_util.py index 36b20fe..48aca80 100644 --- a/sunkit_dem/tests/test_util.py +++ b/sunkit_dem/tests/test_util.py @@ -1,8 +1,9 @@ """ Tests for utilities """ -import pytest import numpy as np +import pytest + import astropy.units as u from sunkit_dem.util import quantity_1d_to_sequence diff --git a/sunkit_dem/util.py b/sunkit_dem/util.py index c251ed6..74919f0 100644 --- a/sunkit_dem/util.py +++ b/sunkit_dem/util.py @@ -1,11 +1,12 @@ """ Utility functions """ -import numpy as np -from astropy.wcs import WCS import ndcube +import numpy as np + import astropy.units as u from astropy.nddata import StdDevUncertainty +from astropy.wcs import WCS __all__ = ["quantity_1d_to_sequence"] diff --git a/sunkit_dem/version.py b/sunkit_dem/version.py new file mode 100644 index 0000000..515c2f0 --- /dev/null +++ b/sunkit_dem/version.py @@ -0,0 +1,17 @@ +# NOTE: First try _dev.scm_version if it exists and setuptools_scm is installed +# This file is not included in wheels/tarballs, so otherwise it will +# fall back on the generated _version module. +try: + try: + from ._dev.scm_version import version + except ImportError: + from ._version import version +except Exception: + import warnings + + warnings.warn( + f'could not determine {__name__.split(".")[0]} package version; this indicates a broken installation' + ) + del warnings + + version = '0.0.0' diff --git a/tox.ini b/tox.ini index 045f999..8c2e03b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,63 +1,78 @@ [tox] +min_version = 4.0 +requires = + tox-pypi-filter>=0.14 envlist = - py{37,38} + py{310,311,312} + py312-devdeps + py310-oldestdeps build_docs codestyle -isolated_build = true -# This is included for testing of the template. You can remove it safely. -skip_missing_interpreters = True -requires = - setuptools >= 30.3.0 - pip >= 19.3.1 - tox-pypi-filter >= 0.10 + build_docs [testenv] - -# The following option combined with the use of the tox-pypi-filter above allows -# project-wide pinning of dependencies, e.g. if new versions of pytest do not -# work correctly with pytest-astropy plugins. Most of the time the pinnings file -# should be empty. -pypi_filter_requirements = https://raw.githubusercontent.com/sunpy/package-template/master/sunpy_version_pins.txt - -# Pass through the following environemnt variables which may be needed for the CI -passenv = HOME WINDIR LC_ALL LC_CTYPE CC CI TRAVIS - +pypi_filter = https://raw.githubusercontent.com/sunpy/sunpy/main/.test_package_pins.txt # Run the tests in a temporary directory to make sure that we don't import # the package from the source tree -changedir = .tmp/{envname} - -# tox environments are constructued with so-called 'factors' (or terms) -# separated by hyphens, e.g. test-devdeps-cov. Lines below starting with factor: -# will only take effect if that factor is included in the environment name. To -# see a list of example environments that can be run, along with a description, -# run: -# -# tox -l -v -# +change_dir = .tmp/{envname} description = run tests - + oldestdeps: with the oldest supported version of key dependencies + devdeps: with the latest developer version of key dependencies +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 + devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple deps = -# The following indicates which extras_require from setup.cfg will be installed + # For packages which publish nightly wheels this will pull the latest nightly + devdeps: numpy>=0.0.dev0 + # Packages without nightly wheels will be built from source like this + # devdeps: git+/~https://github.com/ndcube/ndcube + oldestdeps: minimum_dependencies +# The following indicates which extras_require will be installed extras = - test + tests +commands_pre = + oldestdeps: minimum_dependencies sunkit_dem --filename requirements-min.txt + oldestdeps: pip install -r requirements-min.txt + pip freeze --all --no-input commands = - pytest --pyargs sunkit_dem {toxinidir}/docs --cov sunkit_dem --cov-config={toxinidir}/setup.cfg {posargs} - - -[testenv:build_docs] -changedir = docs -description = invoke sphinx-build to build the HTML docs -extras = docs -commands = - sphinx-build -W -b html . _build/html {posargs} - + # To amend the pytest command for different factors you can add a line + # which starts with a factor like `online: --remote-data=any \` + # If you have no factors which require different commands this is all you need: + pytest \ + -vvv \ + -r fEs \ + --pyargs sunkit_dem \ + --cov-report=xml \ + --cov=sunkit_dem \ + --cov-config={toxinidir}/.coveragerc \ + {toxinidir}/docs \ + {posargs} [testenv:codestyle] +pypi_filter = skip_install = true description = Run all style and file checks with pre-commit deps = pre-commit commands = pre-commit install-hooks - pre-commit run --all-files + pre-commit run --color always --all-files --show-diff-on-failure + +[testenv:build_docs] +description = invoke sphinx-build to build the HTML docs +change_dir = + docs +extras = + docs +commands = + sphinx-build -j auto --color -W --keep-going -b html -d _build/.doctrees . _build/html {posargs}