Skip to content

Systems

Ready-made systems of every science.

They are built from the core and organized by field and subfield.

all_systems(field=None, topics=(), tags=None)

Return the name and the class of every ready-made system.

The systems can be selected by field, by topics, or by capability tags. It takes the role of sklearn.utils.all_estimators. The field and the topics of every class are read from the sources, so selecting by them imports the modules of the selected classes alone. Filtering by capability tags builds every selected class with its default model parameters and reads its tags.

Parameters:

Name Type Description Default
field str | None

The field, such as chemistry, or the field path, such as chemistry/kinetics, to keep, or None for every field.

None
topics str | Sequence[str]

The topic, or the topics, that every kept system lists, such as 'oscillation'.

()
tags Mapping[str, str | Sequence[str]] | None

The capability tags to keep, by field of Tags, each a value or a sequence of values that the tags of a kept system hold, such as {'randomness': 'stochastic'}, or None for any tags.

None

Returns:

Name Type Description
systems list[tuple[str, type[BaseSystem]]]

The name and the class of every kept system, sorted by name.

Raises:

Type Description
RegistryError

A system class is not named with the suffix System, or gives its field, topics, or references with a value computed at run time.

ValidationError

A tag names no field of Tags.

Examples:

>>> from skcomplex.systems import all_systems
>>> [name for name, _ in all_systems(field='chemistry/pattern_formation')]
['BrusselatorSystem', 'GrayScottSystem', 'SchnakenbergSystem']
>>> [name for name, _ in all_systems(field='chemistry', tags={'randomness': 'stochastic'})]
['ChemicalLangevinEquationSystem', 'ChemicalLangevinNetworkSystem']
Source code in src/skcomplex/systems/_catalog.py
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
def all_systems(
    field: str | None = None,
    topics: str | Sequence[str] = (),
    tags: Mapping[str, str | Sequence[str]] | None = None,
) -> list[tuple[str, type[BaseSystem]]]:
    """Return the name and the class of every ready-made system.

    The systems can be selected by field, by topics, or by capability tags. It takes the role of
    `sklearn.utils.all_estimators`. The field and the topics of every class are read from the sources, so selecting by
    them imports the modules of the selected classes alone. Filtering by capability tags builds every selected class
    with its default model parameters and reads its tags.

    Args:
        field:
            The field, such as `chemistry`, or the field path, such as `chemistry/kinetics`, to keep, or `None` for
            every field.

        topics:
            The topic, or the topics, that every kept system lists, such as `'oscillation'`.

        tags:
            The capability tags to keep, by field of `Tags`, each a value or a sequence of values that the tags of a
            kept system hold, such as `{'randomness': 'stochastic'}`, or `None` for any tags.

    Returns:
        systems:
            The name and the class of every kept system, sorted by name.

    Raises:
        RegistryError:
            A system class is not named with the suffix `System`, or gives its field, topics, or references with a
            value computed at run time.

        ValidationError:
            A tag names no field of `Tags`.

    Examples:
        >>> from skcomplex.systems import all_systems
        >>> [name for name, _ in all_systems(field='chemistry/pattern_formation')]
        ['BrusselatorSystem', 'GrayScottSystem', 'SchnakenbergSystem']
        >>> [name for name, _ in all_systems(field='chemistry', tags={'randomness': 'stochastic'})]
        ['ChemicalLangevinEquationSystem', 'ChemicalLangevinNetworkSystem']
    """
    return SYSTEM_CLASSES.get_classes(field, topics, tags)

import_extra(module, system, extra)

Return a module of an optional extra.

When the extra is missing, it raises an error naming the system, the extra, and the install command.

Parameters:

Name Type Description Default
module str

The dotted name of the module.

required
system str

The name of the system that needs the module.

required
extra str

The name of the optional extra that holds the module.

required

Returns:

Name Type Description
module ModuleType

The imported module.

Raises:

Type Description
MissingExtraError

The module is not installed.

Examples:

>>> from skcomplex.systems import import_extra
>>> import_extra('math', 'pendulum', 'none').sqrt(4.0)
2.0
Source code in src/skcomplex/systems/_extras.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def import_extra(module: str, system: str, extra: str) -> ModuleType:
    """Return a module of an optional extra.

    When the extra is missing, it raises an error naming the system, the extra, and the install command.

    Args:
        module:
            The dotted name of the module.

        system:
            The name of the system that needs the module.

        extra:
            The name of the optional extra that holds the module.

    Returns:
        module:
            The imported module.

    Raises:
        MissingExtraError:
            The module is not installed.

    Examples:
        >>> from skcomplex.systems import import_extra
        >>> import_extra('math', 'pendulum', 'none').sqrt(4.0)
        2.0
    """
    try:
        return import_module(module)
    except ImportError as error:
        error_msg = (
            f"The system {system} needs the extra '{extra}'. Install it with "
            f"`pip install 'scikit-complexity[{extra}]'`."
        )
        raise MissingExtraError(error_msg) from error