Skip to content

Commit 49bb84d

Browse files
committed
Merge branch 'main' into docs-spec-object
2 parents f9c7219 + ecda56f commit 49bb84d

56 files changed

Lines changed: 2106 additions & 1408 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cruft.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/sunpy/package-template",
3-
"commit": "aec53b81aed2e7e534045e59303d82712fe82fb1",
3+
"commit": "75bb72f38a9b527937b6a135457418c00b8614a9",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -10,21 +10,29 @@
1010
"author_name": "The SunPy Community",
1111
"author_email": "sunpy@googlegroups.com",
1212
"project_url": "https://sunkit-spex.readthedocs.io",
13+
"github_repo": "",
14+
"sourcecode_url": "",
15+
"download_url": "https://pypi.org/project/sunkit-spex",
16+
"documentation_url": "",
17+
"changelog_url": "",
18+
"issue_tracker_url": "",
1319
"license": "BSD 3-Clause",
1420
"minimum_python_version": "3.10",
1521
"use_compiled_extensions": "n",
1622
"enable_dynamic_dev_versions": "y",
1723
"include_example_code": "n",
1824
"include_cruft_update_github_workflow": "y",
19-
"_sphinx_theme": "alabaster",
25+
"use_extended_ruff_linting": "y",
26+
"_sphinx_theme": "sunpy",
2027
"_parent_project": "",
2128
"_install_requires": "",
2229
"_copy_without_render": [
2330
"docs/_templates",
2431
"docs/_static",
2532
".github/workflows/sub_package_update.yml"
2633
],
27-
"_template": "https://github.com/sunpy/package-template"
34+
"_template": "https://github.com/sunpy/package-template",
35+
"_commit": "75bb72f38a9b527937b6a135457418c00b8614a9"
2836
}
2937
},
3038
"directory": null

.github/workflows/ci.yml

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Main CI Workflow
12
name: CI
23

34
on:
@@ -14,14 +15,21 @@ on:
1415
pull_request:
1516
# Allow manual runs through the web UI
1617
workflow_dispatch:
18+
schedule:
19+
# ┌───────── minute (0 - 59)
20+
# │ ┌───────── hour (0 - 23)
21+
# │ │ ┌───────── day of the month (1 - 31)
22+
# │ │ │ ┌───────── month (1 - 12 or JAN-DEC)
23+
# │ │ │ │ ┌───────── day of the week (0 - 6 or SUN-SAT)
24+
- cron: '0 7 * * 3' # Every Wed at 07:00 UTC
1725

1826
concurrency:
1927
group: ${{ github.workflow }}-${{ github.ref }}
2028
cancel-in-progress: true
2129

2230
jobs:
2331
core:
24-
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
32+
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
2533
with:
2634
submodules: false
2735
coverage: codecov
@@ -45,7 +53,7 @@ jobs:
4553

4654
test:
4755
needs: [core, sdist_verify]
48-
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
56+
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
4957
with:
5058
submodules: false
5159
coverage: codecov
@@ -55,12 +63,13 @@ jobs:
5563
- windows: py311
5664
- macos: py310
5765
- linux: py310-oldestdeps
66+
- linux: py311-devdeps
5867
secrets:
5968
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
6069

6170
docs:
6271
needs: [core]
63-
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
72+
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
6473
with:
6574
default_python: '3.12'
6675
submodules: false
@@ -72,23 +81,6 @@ jobs:
7281
envs: |
7382
- linux: build_docs
7483
75-
cron:
76-
if: |
77-
github.event_name == 'workflow_dispatch' || (
78-
github.event_name == 'pull_request' &&
79-
contains(github.event.pull_request.labels.*.name, 'Run cron CI')
80-
)
81-
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
82-
with:
83-
default_python: '3.12'
84-
submodules: false
85-
coverage: codecov
86-
toxdeps: tox-pypi-filter
87-
envs: |
88-
- linux: py311-devdeps
89-
secrets:
90-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
91-
9284
publish:
9385
# Build wheels on PRs only when labelled. Releases will only be published if tagged ^v.*
9486
# see https://github-actions-workflows.openastronomy.org/en/latest/publish.html#upload-to-pypi
@@ -99,7 +91,7 @@ jobs:
9991
contains(github.event.pull_request.labels.*.name, 'Run publish')
10092
)
10193
needs: [test, docs]
102-
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@main
94+
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v1
10395
with:
10496
python-version: '3.12'
10597
test_extras: 'tests'

.github/workflows/label_sync.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Label Sync
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
# ┌───────── minute (0 - 59)
6+
# │ ┌───────── hour (0 - 23)
7+
# │ │ ┌───────── day of the month (1 - 31)
8+
# │ │ │ ┌───────── month (1 - 12 or JAN-DEC)
9+
# │ │ │ │ ┌───────── day of the week (0 - 6 or SUN-SAT)
10+
- cron: '0 0 * * *' # run every day at midnight UTC
11+
12+
# Give permissions to write issue labels
13+
permissions:
14+
issues: write
15+
16+
jobs:
17+
label_sync:
18+
runs-on: ubuntu-latest
19+
name: Label Sync
20+
steps:
21+
- uses: srealmoreno/label-sync-action@850ba5cef2b25e56c6c420c4feed0319294682fd
22+
with:
23+
config-file: https://raw.githubusercontent.com/sunpy/.github/main/labels.yml

.github/workflows/sub_package_update.yml

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ jobs:
2121
runs-on: ubuntu-latest
2222
strategy:
2323
fail-fast: true
24-
matrix:
25-
include:
26-
- add-paths: .
27-
body: apply the changes to this repo.
28-
branch: cruft/update
29-
commit-message: "Automatic package template update"
30-
title: Updates from the package template
31-
3224
steps:
3325
- uses: actions/checkout@v4
3426

@@ -55,25 +47,49 @@ jobs:
5547
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
5648
5749
- name: Run update if available
50+
id: cruft_update
5851
if: steps.check.outputs.has_changes == '1'
5952
run: |
6053
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
6154
git config --global user.name "${{ github.actor }}"
6255
63-
cruft update --skip-apply-ask --refresh-private-variables
56+
cruft_output=$(cruft update --skip-apply-ask --refresh-private-variables)
57+
echo $cruft_output
6458
git restore --staged .
6559
66-
- name: Create pull request
60+
if [[ "$cruft_output" == *"Failed to cleanly apply the update, there may be merge conflicts."* ]]; then
61+
echo merge_conflicts=1 >> $GITHUB_OUTPUT
62+
else
63+
echo merge_conflicts=0 >> $GITHUB_OUTPUT
64+
fi
65+
66+
- name: Check if only .cruft.json is modified
67+
id: cruft_json
6768
if: steps.check.outputs.has_changes == '1'
69+
run: |
70+
git status --porcelain=1
71+
if [[ "$(git status --porcelain=1)" == " M .cruft.json" ]]; then
72+
echo "Only .cruft.json is modified. Exiting workflow early."
73+
echo "has_changes=0" >> "$GITHUB_OUTPUT"
74+
else
75+
echo "has_changes=1" >> "$GITHUB_OUTPUT"
76+
fi
77+
78+
- name: Create pull request
79+
if: steps.cruft_json.outputs.has_changes == '1'
6880
uses: peter-evans/create-pull-request@v7
6981
with:
7082
token: ${{ secrets.GITHUB_TOKEN }}
71-
add-paths: ${{ matrix.add-paths }}
72-
commit-message: ${{ matrix.commit-message }}
73-
branch: ${{ matrix.branch }}
83+
add-paths: "."
84+
commit-message: "Automatic package template update"
85+
branch: "cruft/update"
7486
delete-branch: true
75-
branch-suffix: timestamp
76-
title: ${{ matrix.title }}
87+
draft: ${{ steps.cruft_update.outputs.merge_conflicts == '1' }}
88+
title: "Updates from the package template"
89+
labels: |
90+
No Changelog Entry Needed
7791
body: |
78-
This is an autogenerated PR, which will ${{ matrix.body }}.
79-
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template
92+
This is an autogenerated PR, which will applies the latest changes from the [SunPy Package Template](https://github.com/sunpy/package-template).
93+
If this pull request has been opened as a draft there are conflicts which need fixing.
94+
95+
**To run the CI on this pull request you will need to close it and reopen it.**

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ docs/sg_execution_times.rst
8282
docs/generated/
8383
examples/rhessi/
8484
examples/sunxspexRhessiSpectralFitting.pickle
85+
examples/nustar/
86+
test.pickle
8587

8688
# PyBuilder
8789
.pybuilder/

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
repos:
22
# This should be before any formatting hooks like isort
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: "v0.6.9"
4+
rev: "v0.11.4"
55
hooks:
66
- id: ruff
77
args: ["--fix"]
88
- id: ruff-format
99
- repo: https://github.com/PyCQA/isort
10-
rev: 5.13.2
10+
rev: 6.0.1
1111
hooks:
1212
- id: isort
1313
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|sunkit_spex/extern)$"
@@ -27,7 +27,7 @@ repos:
2727
- id: mixed-line-ending
2828
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*)$"
2929
- repo: https://github.com/codespell-project/codespell
30-
rev: v2.3.0
30+
rev: v2.4.1
3131
hooks:
3232
- id: codespell
3333
additional_dependencies:

.rtd-environment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: sunkit-spex
22
channels:
33
- conda-forge
44
dependencies:
5-
- python=3.12
5+
- python=3.10
66
- pip
77
- graphviz!=2.42.*,!=2.43.*
8+
- sqlite<3.49.0

.ruff.toml

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,83 @@ exclude = [
1010
]
1111

1212
[lint]
13-
select = ["E", "F", "W", "UP", "PT"]
13+
select = [
14+
"E",
15+
"F",
16+
"W",
17+
"UP",
18+
"PT",
19+
"BLE",
20+
"A",
21+
"C4",
22+
"INP",
23+
"PIE",
24+
"T20",
25+
"RET",
26+
"TID",
27+
"PTH",
28+
"PD",
29+
"PLC",
30+
"PLE",
31+
"FLY",
32+
"NPY",
33+
"PERF",
34+
"RUF",
35+
]
1436
extend-ignore = [
1537
# pycodestyle (E, W)
16-
"E501", # LineTooLong # TODO! fix
38+
"E501", # ignore line length will use a formatter instead
39+
# pyupgrade (UP)
40+
"UP038", # Use | in isinstance - not compatible with models and is slower
1741
# pytest (PT)
1842
"PT001", # Always use pytest.fixture()
19-
"PT004", # Fixtures which don't return anything should have leading _
20-
"PT007", # Parametrize should be lists of tuples # TODO! fix
21-
"PT011", # Too broad exception assert # TODO! fix
2243
"PT023", # Always use () on pytest decorators
44+
# flake8-pie (PIE)
45+
"PIE808", # Disallow passing 0 as the first argument to range
46+
# flake8-use-pathlib (PTH)
47+
"PTH123", # open() should be replaced by Path.open()
48+
# Ruff (RUF)
49+
"RUF003", # Ignore ambiguous quote marks, doesn't allow ' in comments
50+
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
51+
"RUF013", # PEP 484 prohibits implicit `Optional`
52+
"RUF015", # Prefer `next(iter(...))` over single element slice
53+
# PEP8 Naming
54+
"N802", # Function name should be lowercase
55+
"N803", # Argument name should be lowercase
56+
"N806", # Variable in function should be lowercase
57+
"A005", # Module `io` shadows a Python standard-library module
2358
]
2459

2560
[lint.per-file-ignores]
26-
# Part of configuration, not a package.
27-
"setup.py" = ["INP001"]
28-
"conftest.py" = ["INP001"]
61+
"setup.py" = [
62+
"INP001", # File is part of an implicit namespace package.
63+
]
64+
"conftest.py" = [
65+
"INP001", # File is part of an implicit namespace package.
66+
]
2967
"docs/conf.py" = [
30-
"E402", # Module imports not at top of file
31-
"F403"
68+
"E402" # Module imports not at top of file
3269
]
3370
"docs/*.py" = [
34-
"INP001", # Implicit-namespace-package. The examples are not a package.
71+
"INP001", # File is part of an implicit namespace package.
72+
]
73+
"examples/**.py" = [
74+
"T201", # allow use of print in examples
75+
"INP001", # File is part of an implicit namespace package.
76+
]
77+
"__init__.py" = [
78+
"E402", # Module level import not at top of cell
79+
"F401", # Unused import
80+
"F403", # from {name} import * used; unable to detect undefined names
81+
"F405", # {name} may be undefined, or defined from star imports
82+
]
83+
"test_*.py" = [
84+
"E402", # Module level import not at top of cell
85+
]
86+
# Be a bit more lax on legacy
87+
"sunkit_spex/legacy/tests/*.py" = [
88+
"PT011", # `pytest.raises(ValueError)` is too broad
3589
]
36-
"__init__.py" = ["E402", "F401", "F403"]
37-
"test_*.py" = ["B011", "D", "E402", "PGH001", "S101"]
3890

3991
[lint.pydocstyle]
4092
convention = "numpy"

README.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ A package for solar X-ray spectroscopy.
55
:target: http://www.sunpy.org
66
:alt: Powered by SunPy Badge
77

8+
Usage of Generative AI
9+
----------------------
10+
11+
We expect authentic engagement in our community.
12+
Be wary of posting output from Large Language Models or similar generative AI as comments on GitHub or any other platform, as such comments tend to be formulaic and low quality content.
13+
If you use generative AI tools as an aid in developing code or documentation changes, ensure that you fully understand the proposed changes and can explain why they are the correct approach and an improvement to the current state.
14+
815
License
916
-------
1017

changelog/161.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add function `~sunkit_spex.models.physical.albedo.get_albedo_matrix` to calculate Albedo correction for given input spectrum and add model `~sunkit_spex.models.physical.albedo.Albedo` to correct modeled photon spectrum for albedo.

0 commit comments

Comments
 (0)