Skip to content
Projects

methodcard.registry

The registry of every method card, filled on import and keyed by qualified name.

Classes

NameDescription
EntryA registered method: the object, its card and what only exists at runtime.

Functions

NameDescription
cardThe card of a registered class or function (it renders in Jupyter).
entriesThe registered entries, of one top-level package or of all.
loadImport a package and all its submodules, so that every card is registered.
qualified_name<module>.<qualname> of a class or function.
registerAdd an entry; a name registered twice (a module reloaded) is replaced.
registryThe registered classes and functions, of one top-level package or of all.
summaryThe first line of the object's own docstring.

Entryclassdataclass#

class Entry(obj: Any, card: MethodCard, symbolic: Mapping[str, Any] | Callable[[], Mapping[str, Any]] = dict(), problem: Callable[[], Any] | None = None)

A registered method: the object, its card and what only exists at runtime.

Attributes

NameTypeDescription
objAnyThe class or function.
cardMethodCardIts card.
symbolicMapping[str, Any] | Callable[[], Mapping[str, Any]]SymPy rules by equation key (:class:~methodcard.Rule or bare expressions), or a function returning them.
problemCallable[[], Any] | NoneReturns the :class:~methodcard.ConvergenceProblem of the method.

cardattributeinstance attribute#

card: MethodCard

objattributeinstance attribute#

obj: Any

problemattributeclass attributeinstance attribute#

problem: Callable[[], Any] | None = None

symbolicattributeclass attributeinstance attribute#

symbolic: Mapping[str, Any] | Callable[[], Mapping[str, Any]] = field(default_factory=dict)

packageproperty#

package: str

The top-level package the method belongs to.

rulesmethod#

def rules() -> Mapping[str, Any]

The SymPy rules, calling the function that returns them if need be.

cardfunction#

def card(obj: Any) -> MethodCard

The card of a registered class or function (it renders in Jupyter).

Raises

LookupError
If the object has no card.

entriesfunction#

def entries(package: str | None = None) -> dict[str, Entry]

The registered entries, of one top-level package or of all.

Parameters

NameTypeDefaultDescription
packagestr | NoneNoneThe top-level package, e.g. "freeofcharge"; None for all.

Returns

dict[str, Entry]
A copy of the registry, {qualified name: entry}.

loadfunction#

def load(package: str) -> dict[str, BaseException]

Import a package and all its submodules, so that every card is registered.

Modules in a tests subpackage are skipped.

Parameters

NameTypeDescription
packagestrThe top-level package.

Returns

dict[str, BaseException]
The modules that failed to import, with their errors.

qualified_namefunction#

def qualified_name(obj: Any) -> str

<module>.<qualname> of a class or function.

registerfunction#

def register(entry: Entry) -> None

Add an entry; a name registered twice (a module reloaded) is replaced.

registryfunction#

def registry(package: str | None = None) -> dict[str, Any]

The registered classes and functions, of one top-level package or of all.

summaryfunction#

def summary(obj: Any) -> str

The first line of the object’s own docstring.