Skip to content

Commit

Permalink
Merge branch 'main' of github.com:sunpy/ndcube into meta
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair committed Nov 13, 2024
2 parents 39d675d + 60a0c79 commit 256963c
Show file tree
Hide file tree
Showing 48 changed files with 536 additions and 449 deletions.
5 changes: 3 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/sunpy/package-template",
"commit": "7b0225e0a206b7b6249752991334dea7e9ffcfd4",
"commit": "51fb616094a4d7577c8898445aa50effb89afa31",
"checkout": null,
"context": {
"cookiecutter": {
Expand All @@ -16,7 +16,8 @@
"enable_dynamic_dev_versions": "y",
"include_example_code": "n",
"include_cruft_update_github_workflow": "y",
"_sphinx_theme": "alabaster",
"use_extended_ruff_linting": "y",
"_sphinx_theme": "sunpy",
"_parent_project": "",
"_install_requires": "",
"_copy_without_render": [
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/label_sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Label Sync
on:
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 0 * * *' # run every day at midnight UTC

# Give permissions to write issue labels
permissions:
issues: write

jobs:
label_sync:
runs-on: ubuntu-latest
name: Label Sync
steps:
- uses: srealmoreno/label-sync-action@850ba5cef2b25e56c6c420c4feed0319294682fd
with:
config-file: https://raw.githubusercontent.com/sunpy/.github/main/labels.yml
48 changes: 31 additions & 17 deletions .github/workflows/sub_package_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ jobs:
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

Expand All @@ -55,25 +47,47 @@ jobs:
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
- name: Run update if available
id: cruft_update
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
cruft_output=$(cruft update --skip-apply-ask --refresh-private-variables)
echo $cruft_output
git restore --staged .
- name: Create pull request
if [[ "$cruft_output" == *"Failed to cleanly apply the update, there may be merge conflicts."* ]]; then
echo merge_conflicts=1 >> $GITHUB_OUTPUT
else
echo merge_conflicts=0 >> $GITHUB_OUTPUT
fi
- name: Check if only .cruft.json is modified
id: cruft_json
if: steps.check.outputs.has_changes == '1'
run: |
git status --porcelain=1
if [[ "$(git status --porcelain=1)" == " M .cruft.json" ]]; then
echo "Only .cruft.json is modified. Exiting workflow early."
echo "has_changes=0" >> "$GITHUB_OUTPUT"
else
echo "has_changes=1" >> "$GITHUB_OUTPUT"
fi
- name: Create pull request
if: steps.cruft_json.outputs.has_changes == '1'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: ${{ matrix.add-paths }}
commit-message: ${{ matrix.commit-message }}
branch: ${{ matrix.branch }}
add-paths: "."
commit-message: "Automatic package template update"
branch: "cruft/update"
delete-branch: true
branch-suffix: timestamp
title: ${{ matrix.title }}
draft: ${{ steps.cruft_update.outputs.merge_conflicts == '1' }}
title: "Updates from the package template"
body: |
This is an autogenerated PR, which will ${{ matrix.body }}.
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template
This is an autogenerated PR, which will applies the latest changes from the [SunPy Package Template](https://github.com/sunpy/package-template).
If this pull request has been opened as a draft there are conflicts which need fixing.
**To run the CI on this pull request you will need to close it and reopen it.**
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
# This should be before any formatting hooks like isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.6.9"
rev: "v0.7.2"
hooks:
- id: ruff
args: ["--fix"]
Expand Down
71 changes: 56 additions & 15 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
target-version = "py310"
line-length = 110
line-length = 120
exclude = [
".git,",
"__pycache__",
Expand All @@ -12,34 +12,75 @@ select = [
"E",
"F",
"W",
#"UP",
#"PT"
"UP",
"PT",
"BLE",
"A",
"C4",
"INP",
"PIE",
"T20",
"RET",
"TID",
"PTH",
"PD",
"PLC",
"PLE",
"FLY",
"NPY",
"PERF",
"RUF",
]
extend-ignore = [
"E712",
"E721",
# pycodestyle (E, W)
"E501", # LineTooLong # TODO! fix
"E501", # ignore line length will use a formatter instead
# pyupgrade (UP)
"UP038", # Use | in isinstance - not compatible with models and is slower
# numpy
"NPY002", # TODO: migrate from np.random.rand to np.random.Generator
# 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
"PT011", # TODO: except(ValueRaises) is too broad
"PT012", # TODO: except statement is too lengthy
"PT023", # Always use () on pytest decorators
# flake8-pie (PIE)
"PIE808", # Disallow passing 0 as the first argument to range
# flake8-use-pathlib (PTH)
"PTH123", # open() should be replaced by Path.open()
# Ruff (RUF)
"RUF003", # Ignore ambiguous quote marks, doesn't allow ' in comments
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF013", # PEP 484 prohibits implicit `Optional`
"RUF015", # Prefer `next(iter(...))` over single element slice
]

[lint.per-file-ignores]
# Part of configuration, not a package.
"setup.py" = ["INP001"]
"conftest.py" = ["INP001"]
"setup.py" = [
"INP001", # File is part of an implicit namespace package.
]
"conftest.py" = [
"INP001", # File is part of an implicit namespace package.
]
"docs/conf.py" = [
"E402" # Module imports not at top of file
"E402" # Module imports not at top of file
]
"docs/*.py" = [
"INP001", # Implicit-namespace-package. The examples are not a package.
"INP001", # File is part of an implicit namespace package.
]
"examples/**.py" = [
"T201", # allow use of print in examples
"INP001", # File is part of an implicit namespace package.
]
"__init__.py" = [
"E402", # Module level import not at top of cell
"F401", # Unused import
"F403", # from {name} import * used; unable to detect undefined names
"F405", # {name} may be undefined, or defined from star imports
]
"test_*.py" = [
"E402", # Module level import not at top of cell
]
"__init__.py" = ["E402", "F401", "F403"]
"test_*.py" = ["B011", "D", "E402", "PGH001", "S101"]

[lint.pydocstyle]
convention = "numpy"
11 changes: 6 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import warnings
import datetime
from pathlib import Path

from astropy.utils.exceptions import AstropyDeprecationWarning
from matplotlib import MatplotlibDeprecationWarning
Expand Down Expand Up @@ -58,7 +59,7 @@
]

# Add any paths that contain templates here, relative to this directory.
# templates_path = ["_templates"] # NOQA: ERA001
# templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -116,7 +117,7 @@
# 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"] # NOQA: ERA001
# 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,
Expand Down Expand Up @@ -146,11 +147,11 @@
# -- Sphinx Gallery ---------------------------------------------------------

sphinx_gallery_conf = {
'backreferences_dir': os.path.join('generated', 'modules'),
'backreferences_dir': Path('generated/modules'),
'filename_pattern': '^((?!skip_).)*$',
'examples_dirs': os.path.join('..', 'examples'),
'examples_dirs': Path('../examples'),
'within_subsection_order': "ExampleTitleSortKey",
'gallery_dirs': os.path.join('generated', 'gallery'),
'gallery_dirs': Path('generated/gallery'),
'matplotlib_animations': True,
"default_thumb_file": png_icon,
'abort_on_example_error': False,
Expand Down
2 changes: 1 addition & 1 deletion examples/creating_even_spaced_wavelength_visualisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# `sequence=True` causes a sequence of maps to be returned, one for each image file.
sequence_of_maps = sunpy.map.Map(aia_files, sequence=True)
# Sort the maps in the sequence in order of wavelength.
sequence_of_maps.maps = list(sorted(sequence_of_maps.maps, key=lambda m: m.wavelength))
sequence_of_maps.maps = sorted(sequence_of_maps.maps, key=lambda m: m.wavelength)

#############################################################################
# Using an `astropy.units.Quantity` of the wavelengths of the images, we can construct
Expand Down
18 changes: 16 additions & 2 deletions ndcube/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""
======
ndcube
======
A base package for multi-dimensional contiguous and non-contiguous coordinate-aware arrays.
A package for multi-dimensional contiguous and non-contiguous coordinate-aware arrays.
* Homepage: https://github.com/sunpy/ndcube
* Documentation: https://docs.sunpy.org/projects/ndcube/
Expand All @@ -15,4 +16,17 @@
from .ndcube_sequence import NDCubeSequence, NDCubeSequenceBase
from .version import version as __version__

__all__ = ['NDCube', 'NDCubeSequence', "NDCollection", "NDMeta", "ExtraCoords", "GlobalCoords", "ExtraCoordsABC", "GlobalCoordsABC", "NDCubeBase", "NDCubeSequenceBase", "__version__"]

__all__ = [
"NDCube",
"NDCubeSequence",
"NDCollection",
"NDMeta",
"ExtraCoords",
"GlobalCoords",
"ExtraCoordsABC",
"GlobalCoordsABC",
"NDCubeBase",
"NDCubeSequenceBase",
"__version__",
]
4 changes: 2 additions & 2 deletions ndcube/_dev/scm_version.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Try to use setuptools_scm to get the current version; this is only used
# in development installations from the git repository.
import os.path
from pathlib import Path

try:
from setuptools_scm import get_version

version = get_version(root=os.path.join('..', '..'), relative_to=__file__)
version = get_version(root=Path('../..'), relative_to=__file__)
except ImportError:
raise
except Exception as e:
Expand Down
6 changes: 2 additions & 4 deletions ndcube/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,7 @@ def ndcube_2d_ln_lt_uncert(wcs_2d_lt_ln):
shape = (10, 12)
data_cube = data_nd(shape)
uncertainty = astropy.nddata.StdDevUncertainty(data_cube * 0.1)
cube = NDCube(data_cube, wcs=wcs_2d_lt_ln, uncertainty=uncertainty)
return cube
return NDCube(data_cube, wcs=wcs_2d_lt_ln, uncertainty=uncertainty)


@pytest.fixture
Expand All @@ -510,8 +509,7 @@ def ndcube_2d_ln_lt_mask_uncert(wcs_2d_lt_ln):
mask[2, 0] = True
mask[3, 3] = True
mask[4:6, :4] = True
cube = NDCube(data_cube, wcs=wcs_2d_lt_ln, uncertainty=uncertainty, mask=mask)
return cube
return NDCube(data_cube, wcs=wcs_2d_lt_ln, uncertainty=uncertainty, mask=mask)


@pytest.fixture
Expand Down
Loading

0 comments on commit 256963c

Please sign in to comment.