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__() and get() 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 fresh IntegratorRegistry() is

useful 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_integrators mapping.

Return type:

dict[str, Callable]

by_category(category)[source]#

Return all entries belonging to category, sorted by name.

Return type:

list[IntegratorEntry]

entries()[source]#

Iterate over all canonical IntegratorEntry instances.

Return type:

Iterator[IntegratorEntry]

entry(name)[source]#

Return the IntegratorEntry for name.

name may be a canonical name or an alias. Looking up a deprecated entry emits a DeprecationWarning once per name per registry instance.

Return type:

IntegratorEntry

get(name, default=None)[source]#

Return the step function for name, or default if missing.

Return type:

Callable | None

items()[source]#

Iterate over (name, func) pairs for canonical entries only.

Return type:

Iterator[tuple[str, Callable]]

names(*, include_aliases=False)[source]#

Return the sorted list of registered names.

If include_aliases is True, alias names are appended.

Return type:

list[str]

register(name, func, *, aliases=(), category='general', order=None, description='', deprecated=False, override=False)[source]#

Register an integrator under name (and any aliases).

Parameters:
  • name (str) – Canonical name to register. Must not already be present unless override=True.

  • func (Callable) – The integrator step function to associate with name.

  • 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 resulting IntegratorEntry.

  • order (int | None) – Forwarded to the resulting IntegratorEntry.

  • description (str) – Forwarded to the resulting IntegratorEntry.

  • deprecated (bool) – Forwarded to the resulting IntegratorEntry.

  • override (bool) – If True, replace an existing entry with the same canonical name and emit a RuntimeWarning identifying the previous owner. If False (the default), a colliding canonical name raises ValueError.

Returns:

The entry that was inserted.

Return type:

IntegratorEntry

Raises:
  • TypeError – If func is not callable, or name is not a non-empty string.

  • ValueError – If name collides with an existing canonical name or alias and override is False, or if any alias collides with an existing canonical name or alias owned by a different entry.

resolve(name)[source]#

Return the canonical name for name (which may be an alias).

Return type:

str

suggest(name, *, n=1, cutoff=0.6)[source]#

Return up to n close-match suggestions for an unknown name.

Return type:

list[str]

unregister(name)[source]#

Remove the integrator registered as name.

name must be a canonical name; passing an alias raises KeyError. All aliases owned by the entry are removed too.

Return type:

None