Skip to content

Commit

Permalink
Scientiric Python Guide
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmeagher committed Jan 25, 2024
1 parent 14007a8 commit 067c40b
Show file tree
Hide file tree
Showing 12 changed files with 186 additions and 117 deletions.
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: © 2024 the i3astropy contributors
#
# SPDX-License-Identifier: BSD-2-Clause

version: 2
updates:
- package-ecosystem: pip
directory: /
schedule:
interval: weekly
groups:
actions:
patterns:
- "*"
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
actions:
patterns:
- "*"
66 changes: 35 additions & 31 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,53 @@ name: Tests
on:
push:
branches:
- main
- main
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
Tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-22.04]
include:
- python-version: 3.12
os: macos-12
- python-version: 3.12
os: macos-12
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install i3astropy
run: python3 -m pip install .[test]
- name: Run Unit Tests
run: pytest
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false
verbose: true
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install i3astropy
run: python3 -m pip install .[test]
- name: Run Unit Tests
run: pytest
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false
verbose: true
Docs:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: pip
cache-dependency-path: pyproject.toml
- name: Install i3astropy
run: python3 -m pip install .[docs]
- name: Build Docs
run: mkdocs build
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install i3astropy
run: python3 -m pip install .[docs]
- name: Build Docs
run: mkdocs build
138 changes: 74 additions & 64 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,77 @@ ci:
autoupdate_commit_msg: autoupdate pre-commit hooks
autoupdate_schedule: quarterly
repos:
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
hooks:
- id: pretty-format-toml
args: [--autofix]
- id: pretty-format-yaml
args: [--autofix]
- repo: https://github.com/fsfe/reuse-tool
rev: v2.1.0
hooks:
- id: reuse
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
hooks:
- id: ruff
args: [--fix]
- repo: https://github.com/pycqa/pylint
rev: v3.0.3
hooks:
- id: pylint
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: [-L, livetime]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-no-log-warn
- id: python-no-eval
- id: python-use-type-annotations
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
- id: forbid-crlf
- id: forbid-tabs
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: debug-statements
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: name-tests-test
args: [--pytest-test-first]
- id: trailing-whitespace
exclude: \.svg$
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
files: \.ya?ml$
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
hooks:
- id: pretty-format-toml
args: [--autofix]
- repo: https://github.com/fsfe/reuse-tool
rev: v3.0.1
hooks:
- id: reuse
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies: [numpy]
files: src/i3astropy
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
- id: ruff
args: [--fix, --show-fixes]
- id: ruff-format
- repo: https://github.com/pycqa/pylint
rev: v3.0.3
hooks:
- id: pylint
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: [-L, livetime]
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
- id: blacken-docs
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-no-log-warn
- id: python-no-eval
- id: python-use-type-annotations
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
- id: forbid-crlf
- id: forbid-tabs
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: debug-statements
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: name-tests-test
args: [--pytest-test-first]
- id: trailing-whitespace
exclude: \.svg$
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ so that you can test changes without reinstalling the module:
This example takes an event which occurred at DAQ time (2021, 155525688461058500) and was reconstructed in the direction of zenith = 0.73884 rad, azimuth = 2.7348 rad and converts it to RA and Dec.
In addition, get the Sun position in IceCube coordinates at the same time.

```python
```pycon

>>> from astropy.coordinates import ICRS, get_sun
>>> from astropy.time import Time
Expand Down
3 changes: 2 additions & 1 deletion examples/compare_ps_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
from astropy import units as u
from astropy.coordinates import ICRS
from astropy.time import Time
from i3astropy import I3Dir
from numpy import allclose

from i3astropy import I3Dir

# need file from /data/ana/analyses/ps_tracks/version-004-p00/IC86_2019_exp.npy
f = np.load("IC86_2019_exp.npy")
N = 10000
Expand Down
3 changes: 2 additions & 1 deletion examples/plot_analemma.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
from astropy.coordinates import get_sun
from astropy.time import Time
from astropy.units import day
from i3astropy import I3Dir
from matplotlib import ticker

from i3astropy import I3Dir

LEFT_MARGIN, RIGHT_MARGIN = 0.08, 0.02
ANALAMA_WIDTH = 0.2
TOP_MARGIN, BOTTOM_MARGIN = 0.01, 0.08
Expand Down
3 changes: 2 additions & 1 deletion examples/plot_moon.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
from astropy.coordinates import get_moon
from astropy.time import Time
from astropy.units import day
from i3astropy import I3Dir
from matplotlib.dates import DateFormatter, YearLocator
from matplotlib.ticker import FormatStrFormatter

from i3astropy import I3Dir

warnings.simplefilter("ignore")

t0 = Time("2020-01-02 00:00")
Expand Down
3 changes: 2 additions & 1 deletion examples/plot_sun_azimuth.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
from astropy.coordinates import ICRS, get_sun
from astropy.time import Time
from astropy.units import day, deg
from i3astropy import I3Dir
from matplotlib import patches, ticker

from i3astropy import I3Dir


# pylint: disable=R0913
def draw_circ(axis, radius, cent_x, cent_y, angle_, theta2_, color_="black"):
Expand Down
32 changes: 27 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,55 @@ line_length = 108
multi_line_output = 3
use_parentheses = true

[tool.mypy]
allow_subclassing_any = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
exclude = 'docs|examples|tests'
files = 'src/i3astropy'
ignore_missing_imports = true
plugins = "numpy.typing.mypy_plugin"
strict = true
warn_unreachable = true

[tool.pylint.format]
max-line-length = "108"

[tool.pylint.messages_control]
disable = ["W0201", "R0903", "E0401", "C0411"]

[tool.pytest.ini_options]
addopts = "--cov=i3astropy --doctest-glob='README.md'"
addopts = ["--cov=i3astropy", "--doctest-glob=README.md", "-ra", "--strict-config", "--strict-markers"]
filterwarnings = ["error"]
log_cli_level = "INFO"
minversion = 7
testpaths = ["tests", "README.md"]
xfail_strict = true

[tool.ruff]
line-length = 108
show-fixes = true
src = ['src']
target-version = "py39"

[tool.ruff.lint]
fixable = ["I"]
ignore = [
"ANN", # flake8-annotations
"ANN401", # any-type
"INP001", # flake8-no-pep420
"S101", # assert-used
"D213", # multi-line-summary-second-line incompatible with multi-line-summary-first-line
"D203", # one-blank-line-before-class" incompatible with no-blank-line-before-class
"RUF012" # mutable-class-default
]
line-length = 108
select = ["ALL"]
target-version = "py39"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"examples/*" = [
"ANN", # flake8-annotations
"PLR", # max-statements
"ARG", # flake8-unused-arguments
"T201" # flake8-print
]
"tests/*" = [
"ANN" # flake8-annotations
]
Loading

0 comments on commit 067c40b

Please sign in to comment.