IntegratorRegistry#
- class braincell.quad.IntegratorRegistry[source]#
Mutable, observable registry of integrator step functions.
The registry maintains two indexes:
_entries: canonical name →IntegratorEntry_aliases: alias name → canonical name
Lookups via
__getitem__()andget()consult both, so callers do not need to know whether a string is a canonical name or an alias.Most code interacts with the global singleton returned by
get_registry(). Constructing a freshIntegratorRegistry()isuseful in tests that want to avoid touching global state.
- as_dict(*, include_aliases=True)[source]#
Return a flat
{name: func}snapshot.By default the snapshot includes alias keys, matching the behavior of the legacy
all_integratorsmapping.
- by_category(category)[source]#
Return all entries belonging to
category, sorted by name.- Return type:
- entries()[source]#
Iterate over all canonical
IntegratorEntryinstances.- Return type:
- entry(name)[source]#
Return the
IntegratorEntryforname.namemay be a canonical name or an alias. Looking up a deprecated entry emits aDeprecationWarningonce per name per registry instance.- Return type:
- names(*, include_aliases=False)[source]#
Return the sorted list of registered names.
If
include_aliasesisTrue, alias names are appended.
- register(name, func, *, aliases=(), category='general', order=None, description='', deprecated=False, override=False)[source]#
Register an integrator under
name(and anyaliases).- Parameters:
name (
str) – Canonical name to register. Must not already be present unlessoverride=True.func (
Callable) – The integrator step function to associate withname.aliases (
Iterable[str]) – Optional alternative names. Each alias must be unique across the full registry (canonical names and other aliases).category (
str) – Forwarded to the resultingIntegratorEntry.order (
int|None) – Forwarded to the resultingIntegratorEntry.description (
str) – Forwarded to the resultingIntegratorEntry.deprecated (
bool) – Forwarded to the resultingIntegratorEntry.override (
bool) – IfTrue, replace an existing entry with the same canonical name and emit aRuntimeWarningidentifying the previous owner. IfFalse(the default), a colliding canonical name raisesValueError.
- Returns:
The entry that was inserted.
- Return type:
- Raises:
TypeError – If
funcis not callable, ornameis not a non-empty string.ValueError – If
namecollides with an existing canonical name or alias andoverrideis False, or if any alias collides with an existing canonical name or alias owned by a different entry.