Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8de6467
🔧 Update dprint excludes and lefthook configuration for improved linting
munechika-koyo Nov 13, 2025
612a69b
🔧 Set ruff's docstring lint/format
munechika-koyo Nov 14, 2025
6cf51f9
📝 Refactor RST templates for improved readability of generated rst
munechika-koyo Nov 14, 2025
6e1d43d
🙈 Add typings directory to .gitignore
munechika-koyo Nov 14, 2025
7f5babc
➖ Remove numpydoc dependency for document build
munechika-koyo Nov 14, 2025
94bf750
🐛 Fix magnetic axis assignment in load_equilibrium_data function
munechika-koyo Nov 17, 2025
1b856b7
📝 Fix formatting issues in CHANGELOG.md links and update unreleased s…
munechika-koyo Nov 17, 2025
c652dd2
🎨 Set `autoconvert=False` for entry get
munechika-koyo Nov 17, 2025
ff47f77
📝 Add `__call__` and `__getitem__` to special members in class template
munechika-koyo Nov 17, 2025
ad512a8
✨ Enhance ggd classes with type hints and improved docstrings
munechika-koyo Nov 17, 2025
6fd1868
📝 Refactor docstrings for clarity and consistency across dataset modules
munechika-koyo Nov 18, 2025
375986d
🚑 Fix the bug of incorrect indent
munechika-koyo Nov 18, 2025
08fdfe9
Refactor parameter documentation and type hints across multiple modules
munechika-koyo Nov 18, 2025
158f6ac
🧹 Remove unnecessary blank line in species module
munechika-koyo Nov 18, 2025
d6be1ef
🔧 Add mypy plugin for numpy typing and enhance type reporting settings
munechika-koyo Nov 18, 2025
4edb0ad
➕ Add `sphinx-api-relink` dependency for documentation feature
munechika-koyo Nov 18, 2025
81dc1f6
🔧 Update Sphinx configuration: add Napoleon and Sphinx API relink ext…
munechika-koyo Nov 18, 2025
13dfb45
🎨 Enhance plotting functions with detailed docstrings and return type…
munechika-koyo Nov 18, 2025
6f78747
🧹 Remove unnecessary trailing newline in density plotting code
munechika-koyo Nov 18, 2025
4ce6179
🔖 Update CHANGELOG for version 0.2.1
munechika-koyo Nov 18, 2025
d382470
Add ruff ignore option temporally
munechika-koyo Nov 18, 2025
6506886
🔧 Update type hinting for `override` and add `typing-extensions` depe…
munechika-koyo Nov 18, 2025
72ff888
Merge branch 'master' into develop
munechika-koyo Nov 18, 2025
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
2 changes: 1 addition & 1 deletion .dprint.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"formatComments": true,
"braceSpacing": false,
},
"excludes": ["**/*.lock", "dist/"],
"excludes": ["**/*-lock.json", "**/*.lock", "**/node_modules/", "dist/"],
"plugins": [
"https://plugins.dprint.dev/json-0.20.0.wasm",
"https://plugins.dprint.dev/markdown-0.19.0.wasm",
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,8 @@ __marimo__/
# Streamlit
.streamlit/secrets.toml

# Type Stubs
typings/

# Plots
demos/ITER/plots/
16 changes: 2 additions & 14 deletions .lefthook.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
lefthook: pixi run --environment=lint lefthook
lefthook: pixi run --no-progress --environment=lint --frozen lefthook

templates:
run: run --environment=lint
run: run --quiet --no-progress --environment=lint --frozen

colors: true

Expand Down Expand Up @@ -65,18 +65,6 @@ pre-commit:
glob: "pyproject.toml"
run: pixi {run} validate-pyproject {staged_files}

- name: docstring-lint
stage_fixed: true
group:
piped: true
jobs:
- name: docformatter
glob: "*.{py,pyx,pyi}"
run: pixi {run} docformatter --in-place {staged_files}
- name: numpydoc
glob: "*.{py,pyi}"
run: pixi {run} numpydoc {staged_files}

- name: cython-lint
glob: "*.{pyx,pxd}"
run: pixi {run} cython-lint {staged_files}
26 changes: 24 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,30 @@

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https//keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https//semver.org/spec/v2.0.0.html).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.1] - 2025-11-18

### Added

- Add some missing type hints.

### Changed

- Migrate docstring linting/formatting from `numpydoc` and `docformatter` to `ruff`
- Migrate `numpydoc` Python API reference to `napoleon` extension for Sphinx (to enjoy type hinting support)
- Update docstrings to be compatible with the `napoleon` style

### Fixed

- Fix values assignment in `load_equilibrium_data` function (convert to python types)
- Bug fix in `load_unstruct_grid_2d` function (incorrect `cells.append(cell)` line)

### Removed

- Remove `numpydoc` dependency (migrated to `ruff` for docstring linting as well)
- Remove `docformatter` dependency (migrated to `ruff` for docstring formatting as well)

## [0.2.0] - 2025-11-04

Expand Down
8 changes: 4 additions & 4 deletions demos/ITER/camera_geometry_matrix_gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
unsaturated_fraction = 0.95


def read_geometry_matrix_without_reflections(
def read_geometry_matrix_without_reflections( # noqa: D103
shot, run, user, database="ITER_MD", backend=HDF5_BACKEND
):
geometry_matrix = {}
Expand Down Expand Up @@ -96,7 +96,7 @@ def read_geometry_matrix_without_reflections(
return geometry_matrix


def read_geometry_matrix_interpolated(shot, run, user, database="ITER_MD", backend=HDF5_BACKEND):
def read_geometry_matrix_interpolated(shot, run, user, database="ITER_MD", backend=HDF5_BACKEND): # noqa: D103
geometry_matrix = {}

with DBEntry(backend, database, shot, run, user) as entry:
Expand Down Expand Up @@ -235,7 +235,7 @@ def read_geometry_matrix_interpolated(shot, run, user, database="ITER_MD", backe
power = volume[index] * line_emission[il, it][index]
points = np.array([r2d[index], z2d[index]]).T

def f(task, node_points, interp_data, points, power):
def _f(task, node_points, interp_data, points, power):
ibegin = task[0]
iend = task[1]
interp_matrix = griddata(
Expand All @@ -252,7 +252,7 @@ def f(task, node_points, interp_data, points, power):

with ctx.Pool(processes=NPROC) as pool:
results = pool.map(
f,
_f,
tasks,
node_points=node_points,
interp_data=interp_data,
Expand Down
24 changes: 21 additions & 3 deletions demos/ITER/core_plasma_plot_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.colors import SymLogNorm
from matplotlib.figure import Figure

from cherab.core.math import sample3d_grid, samplevector2d
from cherab.imas.datasets import iter_jintrac
Expand All @@ -19,9 +20,26 @@
plt.ion()


def plot_quantity(quantity, extent, title="", logscale=False, symmetric=False):
"""Make a 2D plot of quantity, with a title, optionally on a log scale."""

def plot_quantity(quantity, extent, title="", logscale=False, symmetric=False) -> Figure:
"""Make a 2D plot of quantity, with a title, optionally on a log scale.

Parameters
----------
quantity
2D array of the quantity to plot.
extent
The extent of the plot in the form [xmin, xmax, ymin, ymax].
title
The title of the plot.
logscale
Whether to use a logarithmic scale for the color map.
symmetric
Whether to use a symmetric color map around zero.

Returns
-------
The matplotlib Figure object containing the plot.
"""
fig = plt.figure(figsize=(4.0, 6.0), layout="constrained")
ax = fig.add_subplot(111)
if logscale:
Expand Down
22 changes: 21 additions & 1 deletion demos/ITER/edge_plasma_mesh_and_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.colors import SymLogNorm
from matplotlib.figure import Figure

from cherab.imas.datasets import iter_jintrac
from cherab.imas.ids.common import get_ids_time_slice
Expand All @@ -21,7 +22,26 @@
grid_subset_name = "Cells"


def plot_grid_quantity(grid, quantity, title="", logscale=False, symmetric=False):
def plot_grid_quantity(grid, quantity, title="", logscale=False, symmetric=False) -> Figure:
"""Make a 2D plot of a grid quantity, with a title, optionally on a log scale.

Parameters
----------
grid
The grid object.
quantity
1D array of the quantity to plot on the grid.
title
The title of the plot.
logscale
Whether to use a logarithmic scale for the color map.
symmetric
Whether to use a symmetric color map around zero.

Returns
-------
The matplotlib Figure object containing the plot.
"""
ax = grid.plot_mesh(data=quantity)

if logscale:
Expand Down
24 changes: 21 additions & 3 deletions demos/ITER/edge_plasma_plot_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.colors import SymLogNorm
from matplotlib.figure import Figure

from cherab.core.math import sample3d, sample3d_grid, samplevector2d, samplevector3d_grid
from cherab.imas.datasets import iter_jintrac
Expand All @@ -18,9 +19,26 @@
plt.ion()


def plot_quantity(quantity, extent, title="", logscale=False, symmetric=False):
"""Make a 2D plot of quantity, with a title, optionally on a log scale."""

def plot_quantity(quantity, extent, title="", logscale=False, symmetric=False) -> Figure:
"""Make a 2D plot of quantity, with a title, optionally on a log scale.

Parameters
----------
quantity
2D array of the quantity to plot.
extent
The extent of the plot in the form [xmin, xmax, ymin, ymax].
title
The title of the plot.
logscale
Whether to use a logarithmic scale for the color map.
symmetric
Whether to use a symmetric color map around zero.

Returns
-------
The matplotlib Figure object containing the plot.
"""
fig = plt.figure(figsize=(4.0, 6.0), layout="constrained")
ax = fig.add_subplot(111)
if logscale:
Expand Down
24 changes: 21 additions & 3 deletions demos/ITER/full_plasma_plot_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.colors import SymLogNorm
from matplotlib.figure import Figure

from cherab.core.math import sample3d, sample3d_grid, samplevector2d, samplevector3d_grid
from cherab.imas.datasets import iter_jintrac
Expand All @@ -19,9 +20,26 @@
plt.ion()


def plot_quantity(quantity, extent, title="", logscale=False, symmetric=False):
"""Make a 2D plot of quantity, with a title, optionally on a log scale."""

def plot_quantity(quantity, extent, title="", logscale=False, symmetric=False) -> Figure:
"""Make a 2D plot of quantity, with a title, optionally on a log scale.

Parameters
----------
quantity
2D array of the quantity to plot.
extent
The extent of the plot in the form [xmin, xmax, ymin, ymax].
title
The title of the plot.
logscale
Whether to use a logarithmic scale for the color map.
symmetric
Whether to use a symmetric color map around zero.

Returns
-------
The matplotlib figure object.
"""
fig = plt.figure(figsize=(4.0, 6.0), layout="constrained")
ax = fig.add_subplot(111)
if logscale:
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/plasma/full_plasma.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
" title=\"Density of \" + label,\n",
" clabel=\"[1/m³]\",\n",
" logscale=True,\n",
" )\n"
" )"
]
}
],
Expand Down
32 changes: 15 additions & 17 deletions docs/source/_templates/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,29 @@
.. autoclass:: {{ objname }}
:show-inheritance:
:members:
:special-members: __call__, __getitem__
:inherited-members:

{% block methods %}
{% if all_methods %}
{% block methods %}
{% if all_methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
:template: method.rst

{% for item in all_methods %}
{%- if not item.startswith('_') or item in ['__call__', '__getitem__'] %}
{% for item in all_methods %}
{%- if not item.startswith('_') or item in ['__call__', '__getitem__'] %}
~{{ name }}.{{ item }}
{% endif %}
{%- endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{% endblock %}
{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
:template: attribute.rst
{% for item in attributes %}
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{%- endfor %}
{%- endif %}
{% endblock %}
Loading
Loading