Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 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": "2a6434a5c749ecde69d00b937a3fef27ecbad656",
"commit": "632ed04aee0058dd88dc6b7972ca8f8061fbd6da",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down Expand Up @@ -36,7 +36,7 @@
".github/workflows/zizmor.yml"
],
"_template": "https://github.com/sunpy/package-template",
"_commit": "2a6434a5c749ecde69d00b937a3fef27ecbad656"
"_commit": "632ed04aee0058dd88dc6b7972ca8f8061fbd6da"
}
},
"directory": null
Expand Down
16 changes: 0 additions & 16 deletions .isort.cfg

This file was deleted.

18 changes: 7 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ 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
- id: ruff-format
types: [python]
exclude: *exclude_dirs
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -55,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
Expand All @@ -73,6 +63,12 @@ repos:
types: [rust]
- id: fmt
types: [rust]
- 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"
23 changes: 22 additions & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ select = [
"W",
"UP",
"PT",
"I",
"BLE",
"A",
"C4",
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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"]
6 changes: 2 additions & 4 deletions benchmarks/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
import importlib.metadata
import time

import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -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()

Expand Down
36 changes: 9 additions & 27 deletions python/streamtracer/streamline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Loading