upxo.meshing.gbconformant.pipeline.settings module

Settings of the conformal meshing pipeline: names, types, limits, defaults and versions.

Every setting is described once, in SETTINGS. The defaults, the type and range checks, the stages a setting influences and the migration of settings saved by an older version all derive from that table. Names keep the notebook spelling.

exception upxo.meshing.gbconformant.pipeline.settings.SettingsError[source]

Bases: ValueError

A setting name or value that cannot be used.

class upxo.meshing.gbconformant.pipeline.settings.Setting(key: str, default: Any, kind: str = '', minimum: float | None = None, maximum: float | None = None, choices: tuple = (), auto: bool = False, size: int = 0, container: str = 'tuple', integral: bool = False, stages: tuple = (), unit: str = '', signed_when_changed: bool = False)[source]

Bases: object

One setting: its default, type, limits and the stages whose results it decides.

key: str
default: Any
kind: str = ''

bool | int | float | text | choice | int_choice | sequence | ids | any (derived from the default when empty).

minimum: float | None = None
maximum: float | None = None
choices: tuple = ()
auto: bool = False

None is a valid value and means “decide automatically”.

size: int = 0

Length of a sequence.

container: str = 'tuple'

what a sequence is stored as.

Type:

tuple or list

integral: bool = False

A sequence keeps whole numbers as int.

stages: tuple = ()

Stages whose results depend on this setting.

unit: str = ''

length (voxel edge lengths), factor (a multiple of the voxel edge length), voxels (a count of voxels) or thickness (a number of voxels across).

Type:

What the number measures, so a physical size can be shown beside it

signed_when_changed: bool = False

Left out of the stages’ saved-results signature while it holds its default, so that adding the setting does not make results saved before it existed stale; changing it from the default still does.

upxo.meshing.gbconformant.pipeline.settings.S(key: str, default: Any, **fields) → Setting[source]
upxo.meshing.gbconformant.pipeline.settings.register_settings(extra: Iterable[Setting]) → None[source]

Add extra settings to the table (a set provider’s own settings). Registering a key again replaces it.

upxo.meshing.gbconformant.pipeline.settings.prepare_provider(values: Mapping) → None[source]

Load the set provider values names (SET_PROVIDER) so that its settings are known.

upxo.meshing.gbconformant.pipeline.settings.default_config(extra: Iterable[Setting] = ()) → dict[source]

A fresh, mutable settings dict holding every default (plus those of extra).

upxo.meshing.gbconformant.pipeline.settings.settings_of_stage(stage_id: str) → tuple[str, ...][source]

Names of the settings that decide the results of stage_id.

upxo.meshing.gbconformant.pipeline.settings.migrate_config(config: Mapping, from_version: int) → dict[source]

Bring settings saved at from_version up to CONFIG_VERSION.

upxo.meshing.gbconformant.pipeline.settings.clean_path_text(text: Any) → str[source]

A path as typed or pasted: no surrounding blanks, line ends or quotes.

Windows “Copy as path” puts the path in double quotes; they are not part of the path. A pair of single quotes is removed too; a double quote never belongs to a Windows path, so a stray one at either end goes as well.

upxo.meshing.gbconformant.pipeline.settings.coerce_value(setting: Setting, value: Any) → tuple[Any, str | None][source]

(value, problem): value brought to the setting’s type; problem is None when it was fine.

A value that cannot be used is replaced by the default and described in problem.

upxo.meshing.gbconformant.pipeline.settings.coerce_config(loaded: Mapping, extra: Iterable[Setting] = ()) → tuple[dict, list[str]][source]

Defaults overlaid with loaded values, each brought to its type.

Returns (config, problems). A value that cannot be used falls back to the default and is listed; settings this version does not know are kept.

upxo.meshing.gbconformant.pipeline.settings.load_versioned(loaded: Mapping, version: int, extra: Iterable[Setting] = ()) → tuple[dict, list[str]][source]

Migrate settings saved at version and coerce them; returns (config, problems).

upxo.meshing.gbconformant.pipeline.settings.parse_value(setting: Setting, text: str) → Any[source]

The value a person typed for setting, checked against its type and limits.

upxo.meshing.gbconformant.pipeline.settings.parse_assignment(text: str, extra: Iterable[Setting] = ()) → tuple[str, Any][source]

"KEY=VALUE" -> (KEY, checked value).

upxo.meshing.gbconformant.pipeline.settings.build_config(overrides: Mapping | None = None, *, extra: Iterable[Setting] = (), **named) → dict[source]

Defaults changed by overrides and named values, each checked.

Unknown names and unusable values raise SettingsError.

upxo.meshing.gbconformant.pipeline.settings.differences(defaults: Mapping, current: Mapping) → list[dict][source]

[{key, default, current}, ...] for the settings that differ from defaults.

Settings present only in current are listed with default=None.