Skip to content

Centralize algorithm parameters in grouped Settings with config-file loading#74

Merged
kripnerl merged 1 commit into
developfrom
claude/settings-parametrization-magic-numbers-7rq85x
Jun 11, 2026
Merged

Centralize algorithm parameters in grouped Settings with config-file loading#74
kripnerl merged 1 commit into
developfrom
claude/settings-parametrization-magic-numbers-7rq85x

Conversation

@kripnerl

Copy link
Copy Markdown
Owner

Extract magic numbers (grid resolutions, solver tolerances, search
heuristics, spline parameters, plotting and IO writer defaults) from
equilibrium.py, equi_tools.py, surfaces.py, field_line_tracers.py,
plotting.py, geqdsk.py and omas.py into pleque.config.Settings,
organized into per-topic sections (grid, splines, critical_points,
lcfs, field_line_tracing, flux_surfaces, plotting, io). Function
arguments still override settings per call; settings are now read at
use time instead of being captured at import time.

Settings load from the first existing of: $PLEQUE_CONFIG_FILE,
./pleque.toml, the per-user config dir (%APPDATA%\pleque on Windows,
$XDG_CONFIG_HOME/pleque elsewhere), or a [tool.pleque] table in the
nearest pyproject.toml, with PLEQUE_-prefixed environment variables
taking precedence over files. The winning file is recorded on the
settings object (config_source, config_files_consulted) and
reload_settings() re-reads the configuration at runtime.

The old flat fields moved into sections: npsi_grid -> flux_surfaces.n_psi,
psin0 -> flux_surfaces.psi_n_min, nr_grid/nz_grid -> lcfs.search_grid_nr/nz
(the None sentinel is gone; defaults are 700/1200 directly).

Also fix lcfs_field_line ignoring its vect_no and xp_shift arguments
(they were hardcoded in the track_plasma_boundary call).

Add tests for defaults, precedence, source tracking, env vars and
reload; document the feature in docs/source/configuration.rst (kept in
sync by a test) and README. pydantic-settings gains the toml extra for
Python 3.10 support.

https://claude.ai/code/session_01HRFoBXP3uhqR5cZuURzdhS

…loading

Extract magic numbers (grid resolutions, solver tolerances, search
heuristics, spline parameters, plotting and IO writer defaults) from
equilibrium.py, equi_tools.py, surfaces.py, field_line_tracers.py,
plotting.py, geqdsk.py and omas.py into pleque.config.Settings,
organized into per-topic sections (grid, splines, critical_points,
lcfs, field_line_tracing, flux_surfaces, plotting, io). Function
arguments still override settings per call; settings are now read at
use time instead of being captured at import time.

Settings load from the first existing of: $PLEQUE_CONFIG_FILE,
./pleque.toml, the per-user config dir (%APPDATA%\pleque on Windows,
$XDG_CONFIG_HOME/pleque elsewhere), or a [tool.pleque] table in the
nearest pyproject.toml, with PLEQUE_-prefixed environment variables
taking precedence over files. The winning file is recorded on the
settings object (config_source, config_files_consulted) and
reload_settings() re-reads the configuration at runtime.

The old flat fields moved into sections: npsi_grid -> flux_surfaces.n_psi,
psin0 -> flux_surfaces.psi_n_min, nr_grid/nz_grid -> lcfs.search_grid_nr/nz
(the None sentinel is gone; defaults are 700/1200 directly).

Also fix lcfs_field_line ignoring its vect_no and xp_shift arguments
(they were hardcoded in the track_plasma_boundary call).

Add tests for defaults, precedence, source tracking, env vars and
reload; document the feature in docs/source/configuration.rst (kept in
sync by a test) and README. pydantic-settings gains the toml extra for
Python 3.10 support.

https://claude.ai/code/session_01HRFoBXP3uhqR5cZuURzdhS
@kripnerl kripnerl merged commit f0ed539 into develop Jun 11, 2026
8 checks passed
@kripnerl kripnerl deleted the claude/settings-parametrization-magic-numbers-7rq85x branch June 12, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants