Skip to content

Backend

abc

Abstract base class for flepimop2 file IO backends.

BackendABC

Bases: ModuleABC

Abstract base class for flepimop2 file IO backends.

read(run_meta)

Read a numpy array from storage.

Parameters:

Name Type Description Default
run_meta RunMeta

Metadata about the current run.

required

Returns:

Type Description
Float64NDArray

The numpy array read from storage.

Source code in src/flepimop2/backend/abc/__init__.py
28
29
30
31
32
33
34
35
36
37
38
def read(self, run_meta: RunMeta) -> Float64NDArray:
    """
    Read a numpy array from storage.

    Args:
        run_meta: Metadata about the current run.

    Returns:
        The numpy array read from storage.
    """
    return self._read(run_meta)
save(data, run_meta)

Save a numpy array to storage.

Parameters:

Name Type Description Default
data Float64NDArray

The numpy array to save.

required
run_meta RunMeta

Metadata about the current run.

required
Source code in src/flepimop2/backend/abc/__init__.py
18
19
20
21
22
23
24
25
26
def save(self, data: Float64NDArray, run_meta: RunMeta) -> None:
    """
    Save a numpy array to storage.

    Args:
        data: The numpy array to save.
        run_meta: Metadata about the current run.
    """
    return self._save(data, run_meta)

build(config)

Build a BackendABC from a configuration dictionary.

Parameters:

Name Type Description Default
config dict[str, Any] | ModuleModel

Configuration dictionary. The dict must contains a 'module' key, which will be used to lookup the Backend module path. The module will have "flepimop2.backend." prepended.

required

Returns:

Type Description
BackendABC

The constructed backend instance.

Source code in src/flepimop2/backend/abc/__init__.py
51
52
53
54
55
56
57
58
59
60
61
62
63
def build(config: dict[str, Any] | ModuleModel) -> BackendABC:
    """Build a `BackendABC` from a configuration dictionary.

    Args:
        config: Configuration dictionary. The dict must contains a 'module' key, which
            will be used to lookup the Backend module path. The module will have
            "flepimop2.backend." prepended.

    Returns:
        The constructed backend instance.

    """
    return _build(config, "backend", "flepimop2.backend.csv", BackendABC)  # type: ignore[type-abstract]

csv

CSV backend for flepimop2.

CsvBackend

Bases: ModuleModel, BackendABC

CSV backend for saving numpy arrays to CSV files.