Skip to content

Commit

Permalink
Merge branch 'main' of github.com:HinodeXRT/xrtpy into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nabobalis committed Oct 17, 2024
2 parents 8d14b47 + 0642933 commit 828fa92
Show file tree
Hide file tree
Showing 22 changed files with 345 additions and 538 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ jobs:

- name: Tests, Python 3.12, Windows
os: windows-latest
noxenv: tests-3.12
noxenv: tests
python: '3.12'
noxposargs: --durations=10

- name: Tests, Python 3.11, Windows
os: windows-latest
noxenv: tests-3.11
noxenv: tests
python: '3.11'
noxposargs: --durations=10

- name: Tests, Python 3.10, macOS
os: macos-latest
noxenv: tests-3.10
noxenv: tests
python: '3.10'

- name: Tests, Python 3.10, Linux
os: ubuntu-latest
noxenv: tests-3.10
noxenv: tests
python: '3.10'

- name: Import XRTpy, Python 3.10, Linux
Expand Down Expand Up @@ -101,4 +101,4 @@ jobs:
run: sudo apt install graphviz

- name: Build documentation
run: nox -s build_docs_nitpicky -- -q
run: nox -s docs
24 changes: 7 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ci:
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-ast
name: validate Python code
Expand All @@ -23,7 +23,7 @@ repos:
- id: check-yaml

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.2
rev: 0.29.4
hooks:
- id: check-github-workflows

Expand All @@ -47,11 +47,6 @@ repos:
args: [--autofix]
- id: pretty-format-yaml
args: [--autofix]
# For the labeler GitHub Action, labels with spaces in them must
# be put in quotes. However, the pretty-format-yaml hook will
# remove the quotes which will break that action (and certain other
# actions).
exclude: .github/labeler.yml|.pre-commit-search-and-replace.yaml

- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
Expand All @@ -62,8 +57,6 @@ repos:
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
name: noqa comments have an error code
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
Expand All @@ -79,30 +72,27 @@ repos:
exclude: .*\.fits

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.3
rev: v0.7.0
hooks:
- id: ruff
name: ruff (see https://docs.astral.sh/ruff/rules)
name: ruff
args: [--fix]
- id: ruff-format
name: autoformat source code with ruff formatter

- repo: https://github.com/asottile/blacken-docs
rev: 1.18.0
rev: 1.19.0
hooks:
- id: blacken-docs
name: autoformat code blocks in docs
additional_dependencies:
- black==24.1.1
- black

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.8.7
hooks:
- id: nbqa-check-ast
name: validate Python notebooks
- id: nbqa-ruff
name: ruff for notebooks (see https://docs.astral.sh/ruff/rules)
args: [--fix, '--select=A,ARG,B,BLE,C,C4,E,F,FLY,I,INT,ISC,PERF,PIE,PLC,PLE,PYI,Q003,RET,RSE,SIM,TID,TRY,UP,W', '--ignore=B018,E402,E501,PLC2401,TRY003']
- id: nbqa-black
additional_dependencies:
- black==24.1.1
- black
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ formats:
- htmlzip

build:
os: ubuntu-22.04
os: ubuntu-lts-latest
tools:
python: '3.11'
python: latest
apt_packages:
- graphviz
jobs:
Expand Down
79 changes: 79 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
target-version = "py310"
show-fixes = true
extend-exclude = [
".jupyter",
"__pycache__",
"_build",
"_dev",
]

[lint]
# Find info about ruff rules at: https://docs.astral.sh/ruff/rules
extend-select = [
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"C90", # mccabe
"COM818", # trailing-comma-on-bare-tuple
"FBT003", # flake8-boolean-trap
"FLY", # flynt
"I", # isort
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"NPY", # numpy-deprecated-type-alias
"PD", # pandas-vet
"PERF", # perflint
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PLC", # pylint convention
"PLE", # pylint errors
"PLW", # pylint warnings
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"PYI", # flake8-pyi
"RSE", # flake8-raise
"RUF005",# collection-literal-concatenation
"RUF006", # asyncio-dangling-task
"RUF007", # pairwise-over-zipped
"RUF008", # mutable-dataclass-default
"RUF009", # function-call-in-dataclass-default-argument
"RUF010", # explicit-f-string-type-conversion
"RUF013", # implicit-optional
"RUF015", # unnecessary-iterable-allocation-for-first-element
"RUF016", # invalid-index-type
"RUF100", # unused-noqa
"RUF200", # invalid-pyproject-toml
"S", # flake8-bandit
"SIM", # flake8-simplify
"TCH", # flake8-type-checking
"TID", # flake8-tidy-imports
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle warnings
]
ignore = [
"C901", # is too complex
"E501", # line-too-long
"ISC001", # single-line-implicit-string-concatenation (formatter conflict)
"N802", # invalid-function-name
"N803", # invalid-argument-name
"N806", # non-lowercase-variable-in-function
"N816", # mixed-case-variable-in-global-scope
"PLC2401", # non-ascii-name
"S101", # asserts
"SIM108", # if-else-block-instead-of-if-exp
"TRY003", # raise-vanilla-args
]

[lint.per-file-ignores]
"docs/conf.py" = [
"E402", # Module imports not at top of file
"INP001", # Implicit-namespace-package. The examples are not a package.
]
"examples/*" = [
"INP001", # Implicit-namespace-package. The examples are not a package.
]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
[![Read the Docs Status](https://readthedocs.org/projects/xrtpy/badge/?version=latest&logo=twitter)](http://xrtpy.readthedocs.io/en/latest/?badge=latest)
[![astropy](http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat&logo=astropy)](http://www.astropy.org/)

XRTpy is a Python package being developed for the analysis of observations made by the X-Ray Telescope (XRT) on the *Hinode* spacecraft.
XRTpy is a Python package being developed for the analysis of observations made by the X-Ray Telescope (XRT) on the **Hinode** spacecraft.

## Acknowledgements

The development of XRTpy is supported by NASA contract NNM07AB07C to the Smithsonian Astrophysical Observatory.
The development of XRTpy is supported by NASA contract **NNM07AB07C** to the Smithsonian Astrophysical Observatory.
11 changes: 4 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
os.environ["PARFIVE_HIDE_PROGRESS"] = "True"

# -- Imports -------------------------------------------------------------------
from astropy.utils.exceptions import AstropyDeprecationWarning # NOQA: E402
from matplotlib import MatplotlibDeprecationWarning # NOQA: E402
from sunpy.util.exceptions import ( # NOQA: E402
from astropy.utils.exceptions import AstropyDeprecationWarning
from matplotlib import MatplotlibDeprecationWarning
from sunpy.util.exceptions import (
SunpyDeprecationWarning,
SunpyPendingDeprecationWarning,
)
Expand All @@ -34,7 +34,7 @@
copyright = f"2021-{datetime.now(tz=UTC).year}, {author}"

# The full version, including alpha/beta/rc tags
from xrtpy import __version__ # NOQA: E402
from xrtpy import __version__

_version_ = Version(__version__)
# NOTE: Avoid "post" appearing in version string in rendered docs
Expand Down Expand Up @@ -85,11 +85,9 @@
# ones.
extensions = [
"hoverxref.extension",
"matplotlib.sphinxext.plot_directive",
"sphinx_automodapi.automodapi",
"sphinx_automodapi.smart_resolver",
"sphinx_copybutton",
"sphinx_design",
"sphinx_gallery.gen_gallery",
"sphinx_issues",
"sphinx.ext.autodoc",
Expand Down Expand Up @@ -176,7 +174,6 @@

# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": (
"https://docs.python.org/3/",
Expand Down
4 changes: 2 additions & 2 deletions examples/effective_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
plt.figure()

plt.plot(
eaf.channel_wavelength,
eaf.wavelength,
effective_area,
label=f"{date_time}",
)
plt.plot(
eaf.channel_wavelength,
eaf.wavelength,
launch_effective_area,
label=f"{relative_launch_date_time}",
)
Expand Down
66 changes: 25 additions & 41 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,69 +1,53 @@
import nox

nox.options.sessions = ["tests", "linters"]

nox.options.sessions = ["tests"]
python_versions = ("3.10", "3.11", "3.12")

sphinx_paths = ["docs", "docs/_build/html"]
sphinx_fail_on_warnings = ["-W", "--keep-going"]
sphinx_builder = ["-b", "html"]
sphinx_opts = sphinx_paths + sphinx_fail_on_warnings + sphinx_builder
sphinx_no_notebooks = ["-D", "nbsphinx_execute=never"]
sphinx_nitpicky = ["-n"]

pytest_options = [
"--ignore",
"xrtpy/response/effective_area.py",
"--ignore",
"xrtpy/response/temperature_response.py",
]


@nox.session(python=python_versions)
@nox.session
def tests(session):
session.install(".[dev,tests]")
"""
Run tests with pytest.
"""
pytest_options = {}
session.install(".[tests]")
session.run("pytest", *pytest_options)


@nox.session
def linters(session):
"""
Run all pre-commit hooks on all files.
"""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files", *session.posargs)


@nox.session
def import_package(session):
"""
Import xrtpy.
"""
session.install(".")
session.run("python", "-c", 'import xrtpy') # fmt: skip
session.run("python", "-c", "import xrtpy")


@nox.session
def build_docs(session):
session.install(".[dev,docs]")
session.run(
"sphinx-build",
*sphinx_opts,
*session.posargs,
def docs(session):
"""
Build documentation with Sphinx.
"""
sphinx_paths = ["docs", "docs/_build/html"]
sphinx_fail_on_warnings = ["-W", "--keep-going"]
sphinx_builder = ["-b", "html"]
sphinx_nitpicky = ["-n"]
sphinx_opts = (
sphinx_paths + sphinx_fail_on_warnings + sphinx_builder + sphinx_nitpicky
)


@nox.session
def build_docs_nitpicky(session):
session.install(".[dev,docs]")
session.install(".[docs]")
session.run(
"sphinx-build",
*sphinx_opts,
*sphinx_nitpicky,
*session.posargs,
)


@nox.session
def build_docs_no_examples(session):
session.install(".[dev,docs]")
session.run(
"sphinx-build",
*sphinx_opts,
*sphinx_no_notebooks,
*session.posargs,
)
Loading

0 comments on commit 828fa92

Please sign in to comment.