Skip to content

offline

OfflineEnvironment()

Bases: TransformedObservable

Base class for offline environments.

Offline environments are used to represent datasets. They can be used to represent static datasets. Offline environments can be transformed and joined together to create new datasets.

Initialize the offline environment.

Source code in src/flowcean/core/environment/offline.py
20
21
22
def __init__(self) -> None:
    """Initialize the offline environment."""
    super().__init__()

chain(*other)

Chain this offline environment with other offline environments.

Chaining offline environments will create a new incremental environment that will first observe the data from this environment and then the data from the other environments.

Parameters:

Name Type Description Default
other OfflineEnvironment

The other offline environments to chain.

()

Returns:

Type Description
ChainedOfflineEnvironments

The chained offline environments.

Source code in src/flowcean/core/environment/offline.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def chain(self, *other: OfflineEnvironment) -> ChainedOfflineEnvironments:
    """Chain this offline environment with other offline environments.

    Chaining offline environments will create a new incremental environment
    that will first observe the data from this environment and then the
    data from the other environments.

    Args:
        other: The other offline environments to chain.

    Returns:
        The chained offline environments.
    """
    from flowcean.core.environment.chained import (
        ChainedOfflineEnvironments,
    )

    return ChainedOfflineEnvironments([self, *other])

__add__(other)

Shorthand for chain.

Source code in src/flowcean/core/environment/offline.py
43
44
45
def __add__(self, other: OfflineEnvironment) -> ChainedOfflineEnvironments:
    """Shorthand for `chain`."""
    return self.chain(other)

hash() abstractmethod

Return the hash of the offline environment.

The hash of the offline environment is used to uniquely identify the data of an environment, mainly for caching purposes. The following properties should be considered when computing the hash:

  • If two environments are equal (e.g. are the same object), they must have the same hash.
  • If two environments of the same type have the same hash, their data must be equal.
  • If two environments have different data, their hashes must be different.

These properties leave one special case open: If two environments share the same data, the hash may be different even if the data is not. The hash is just a way of quickly checking if there is a chance that the data is different between two environments.

Returns:

Type Description
bytes

The hash of the offline environment.

Source code in src/flowcean/core/environment/offline.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@abstractmethod
def hash(self) -> bytes:
    """Return the hash of the offline environment.

    The hash of the offline environment is used to uniquely identify the
    data of an environment, mainly for caching purposes. The following
    properties should be considered when computing the hash:

    - If two environments are equal (e.g. are the same object),
      they must have the same hash.
    - If two environments of the same type have the same hash, their data
      must be equal.
    - If two environments have different data, their hashes must be
      different.

    These properties leave one special case open: If two environments share
    the same data, the hash may be different even if the data is not.
    The hash is just a way of quickly checking if there is a chance that
    the data is different between two environments.

    Returns:
        The hash of the offline environment.
    """