From 2bacafee618815690468a2a9b49943a4ac75ea8b Mon Sep 17 00:00:00 2001 From: Cadair <1391051+Cadair@users.noreply.github.com> Date: Wed, 19 Aug 2026 16:57:44 +0000 Subject: [PATCH 1/3] Run cruft update from package template --- .cruft.json | 4 ++-- .isort.cfg | 16 ---------------- .pre-commit-config.yaml | 6 ------ .ruff.toml | 23 ++++++++++++++++++++++- 4 files changed, 24 insertions(+), 25 deletions(-) delete mode 100644 .isort.cfg diff --git a/.cruft.json b/.cruft.json index db1d057..77012d0 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "https://github.com/sunpy/package-template", - "commit": "2a6434a5c749ecde69d00b937a3fef27ecbad656", + "commit": "c7bfa729646a7e17ae0e7c50c331e5c489f98fe2", "checkout": null, "context": { "cookiecutter": { @@ -36,7 +36,7 @@ ".github/workflows/zizmor.yml" ], "_template": "https://github.com/sunpy/package-template", - "_commit": "2a6434a5c749ecde69d00b937a3fef27ecbad656" + "_commit": "c7bfa729646a7e17ae0e7c50c331e5c489f98fe2" } }, "directory": null diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index 13e23a1..0000000 --- a/.isort.cfg +++ /dev/null @@ -1,16 +0,0 @@ -[settings] -balanced_wrapping = true -skip = - docs/conf.py - streamtracer/__init__.py -default_section = THIRDPARTY -include_trailing_comma = true -known_astropy = astropy, asdf -known_sunpy = sunpy -known_first_party = streamtracer -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 49f3ad3..6c4436e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,12 +8,6 @@ repos: types: [python] # Define here once and then reference using YAML anchor exclude: &exclude_dirs ^streamtracer/(data|extern)/ - - repo: https://github.com/PyCQA/isort - rev: 8.0.1 - hooks: - - id: isort - types: [python] - exclude: *exclude_dirs - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: diff --git a/.ruff.toml b/.ruff.toml index c5b9068..2342fe5 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -14,6 +14,7 @@ select = [ "W", "UP", "PT", + "I", "BLE", "A", "C4", @@ -56,7 +57,8 @@ extend-ignore = [ "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 + "I", # isort ] "docs/*.py" = [ "INP001", # File is part of an implicit namespace package. @@ -70,6 +72,7 @@ extend-ignore = [ "F401", # Unused import "F403", # from {name} import * used; unable to detect undefined names "F405", # {name} may be undefined, or defined from star imports + "I", # isort ] "test_*.py" = [ "E402", # Module level import not at top of cell @@ -80,3 +83,21 @@ extend-ignore = [ [lint.pydocstyle] convention = "numpy" + +[lint.isort] +default-section = "third-party" +section-order = [ + "future", + "standard-library", + "third-party", + "astropy", + "sunpy", + "first-party", + "local-folder", +] +known-first-party = ["streamtracer"] +no-lines-before = ["local-folder"] + +[lint.isort.sections] +"astropy" = ["astropy", "asdf", "gwcs", "reproject"] +"sunpy" = ["sunpy"] From 6350fda7c971c1bdaa58d6eda23267786358a808 Mon Sep 17 00:00:00 2001 From: SunPyBot Date: Thu, 20 Aug 2026 06:53:25 +0000 Subject: [PATCH 2/3] Run cruft update from package template --- .cruft.json | 4 ++-- .pre-commit-config.yaml | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.cruft.json b/.cruft.json index 77012d0..c5adb0a 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "https://github.com/sunpy/package-template", - "commit": "c7bfa729646a7e17ae0e7c50c331e5c489f98fe2", + "commit": "632ed04aee0058dd88dc6b7972ca8f8061fbd6da", "checkout": null, "context": { "cookiecutter": { @@ -36,7 +36,7 @@ ".github/workflows/zizmor.yml" ], "_template": "https://github.com/sunpy/package-template", - "_commit": "c7bfa729646a7e17ae0e7c50c331e5c489f98fe2" + "_commit": "632ed04aee0058dd88dc6b7972ca8f8061fbd6da" } }, "directory": null diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6c4436e..fbf3b05 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -66,7 +66,19 @@ repos: args: ["--allow-staged", "--fix", "--", "-A", "clippy::needless_return", "-W", "clippy::implicit_return"] types: [rust] - id: fmt +<<<<<<< types: [rust] +======= + args: [ "--write-changes" ] + types_or: [python, rst] + exclude: *exclude_dirs + - repo: https://github.com/sphinx-contrib/sphinx-lint + rev: v1.0.2 + hooks: + - id: sphinx-lint + types_or: [python, rst] + exclude: *exclude_dirs +>>>>>>> ci: autofix_prs: false autoupdate_schedule: "quarterly" From eef221c47283d69f94fed64e8c13b4e9d09b7838 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Thu, 20 Aug 2026 09:38:18 +0100 Subject: [PATCH 3/3] Update pre-commit --- .pre-commit-config.yaml | 16 +++----------- benchmarks/benchmark.py | 6 ++---- python/streamtracer/streamline.py | 36 ++++++++----------------------- 3 files changed, 14 insertions(+), 44 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fbf3b05..dd1a746 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,6 +8,9 @@ repos: types: [python] # Define here once and then reference using YAML anchor exclude: &exclude_dirs ^streamtracer/(data|extern)/ + - id: ruff-format + types: [python] + exclude: *exclude_dirs - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: @@ -49,13 +52,6 @@ repos: types: [python] exclude: *exclude_dirs additional_dependencies: [types-setuptools] - # Python code formatting - - repo: https://github.com/psf/black - rev: 24.4.2 - hooks: - - id: black - types: [python] - exclude: *exclude_dirs # Rust code formatting - repo: https://github.com/FeryET/pre-commit-rust rev: v1.1.0 @@ -66,19 +62,13 @@ repos: args: ["--allow-staged", "--fix", "--", "-A", "clippy::needless_return", "-W", "clippy::implicit_return"] types: [rust] - id: fmt -<<<<<<< types: [rust] -======= - args: [ "--write-changes" ] - types_or: [python, rst] - exclude: *exclude_dirs - repo: https://github.com/sphinx-contrib/sphinx-lint rev: v1.0.2 hooks: - id: sphinx-lint types_or: [python, rst] exclude: *exclude_dirs ->>>>>>> ci: autofix_prs: false autoupdate_schedule: "quarterly" diff --git a/benchmarks/benchmark.py b/benchmarks/benchmark.py index f605ea4..667818e 100644 --- a/benchmarks/benchmark.py +++ b/benchmarks/benchmark.py @@ -1,5 +1,5 @@ -import time import importlib.metadata +import time import matplotlib.pyplot as plt import numpy as np @@ -32,9 +32,7 @@ times += [np.mean(dts)] -pd.DataFrame({"nseeds": seedlist, "time": times}).to_csv( - f"v{__version__.replace('.', '')}.csv" -) +pd.DataFrame({"nseeds": seedlist, "time": times}).to_csv(f"v{__version__.replace('.', '')}.csv") fig, ax = plt.subplots() diff --git a/python/streamtracer/streamline.py b/python/streamtracer/streamline.py index ddac445..0113030 100755 --- a/python/streamtracer/streamline.py +++ b/python/streamtracer/streamline.py @@ -45,17 +45,11 @@ def __init__( grid_coords=None, ): if grid_spacing is not None and grid_coords is not None: - raise ValueError( - 'Only one of "grid_spacing" and "grid_coords" can be specified.' - ) + raise ValueError('Only one of "grid_spacing" and "grid_coords" can be specified.') if grid_spacing is None and grid_coords is None: - raise ValueError( - 'One of "grid_spacing" and "grid_coords" must be specified.' - ) + raise ValueError('One of "grid_spacing" and "grid_coords" must be specified.') if grid_coords is not None and origin_coord is not None: - raise ValueError( - 'Specifying both "grid_coords" and "origin_coord" is ambiguous.' - ) + raise ValueError('Specifying both "grid_coords" and "origin_coord" is ambiguous.') self.grid_spacing = grid_spacing self.vectors = vectors self.cyclic = cyclic @@ -74,9 +68,7 @@ def grid_spacing(self, val): if val is not None: val = np.array(val) if val.shape != (3,): - raise ValueError( - f"grid spacing must have shape (3,), got " f"{val.shape}" - ) + raise ValueError(f"grid spacing must have shape (3,), got {val.shape}") self._grid_spacing = val @property @@ -91,9 +83,7 @@ def vectors(self, val): if len(val.shape) != 4: raise ValueError("vectors must be a 4D array") if val.shape[-1] != 3: - raise ValueError( - "vectors must have shape (nx, ny, nz, 3), " f"got {val.shape}" - ) + raise ValueError(f"vectors must have shape (nx, ny, nz, 3), got {val.shape}") self._vectors = val @property @@ -111,10 +101,7 @@ def coords(self, val): for i, dim in zip(range(3), ["x", "y", "z"]): shape = np.array(val[i]).shape if shape != (self.vectors.shape[i],): - raise ValueError( - f"Expected {self.vectors.shape[i]} {dim} " - f"coordinates but got {shape}" - ) + raise ValueError(f"Expected {self.vectors.shape[i]} {dim} coordinates but got {shape}") self._coords = val @property @@ -160,18 +147,13 @@ def origin_coord(self, val): if self.grid_spacing is not None: self._origin_coord = np.array([0, 0, 0]) else: - self._origin_coord = np.array( - [self.xcoords[0], self.ycoords[0], self.zcoords[0]] - ) + self._origin_coord = np.array([self.xcoords[0], self.ycoords[0], self.zcoords[0]]) else: self._origin_coord = np.array(val) def _get_coords(self, i): if self.grid_spacing is not None: - return ( - self.grid_spacing[i] * np.arange(self.vectors.shape[i]) - + self.origin_coord[i] - ) + return self.grid_spacing[i] * np.arange(self.vectors.shape[i]) + self.origin_coord[i] return self.coords[i] @property @@ -263,7 +245,7 @@ def max_steps(self, val): raise ValueError(f"max_steps must be an integer (got {type(val)})") if not val > 0: - raise ValueError("max_steps must be greater than zero " f"(got {val})") + raise ValueError(f"max_steps must be greater than zero (got {val})") self._max_steps = val