tethys.core.networks.network_zero

Module Contents

class tethys.core.networks.network_zero.ZeroNetwork(*pipes: Union[Iterable[Union['ZeroPipe', str]], Union['ZeroPipe', str]], **kwargs)[source]

Bases: tethys.core.regobjs.regobj_zero.ZeroRegistrableObject, tethys.core.networks.network_base.NetworkBase

The Network entity class of the Zero generation. The ZeroNetwork is a container of the Pipes.

Example:
pipe1 = ZeroPipe(
    node_a=node1,
    node_b=node2
)

pipe2 = ZeroPipe(
    node_a=node2,
    node_b=node1
)

pipe3 = ZeroPipe(
    node_a=node3,
    node_b=node1
)

pipe4 = ZeroPipe(
    node_a=node3,
    node_b=node2
)

network_template = ZeroNetwork([pipe1, pipe2])

network = ZeroNetwork()
network.add_pipes(pipe3, pipe4)

result_network = network_template + network
Parameters

pipes (Iterable[Union[ZeroPipe, str]) – list of args of the pipes (str or PipeZero instances) - can be empty

CLASS_PATH = /networks/[source]

ZeroNetwork instances collection path in the repository

FIELDS_SCHEMA[source]

ZeroNetwork fields validators

property pipes(self) → Dict[str, ZeroPipe][source]
property input_nodes(self) → Iterator['ZeroNode'][source]

It returns input nodes

Example:

<in> —> Node1 —> Node2 —> <out>

Node1 - input node

Returns

list of the input nodes

Return type

Iterable[ZeroNode]

property output_nodes(self) → Iterator['ZeroNode'][source]

It returns output nodes

Example:

<in> —> Node1 —> Node2 —> <out>

Node2 - output node (because –> <out>)

Returns

list of the output nodes

Return type

Iterable[ZeroNode]

property input_pipes(self) → Iterator[ZeroPipe][source]

It returns input pipes

Example:

<in> –pipe1–> N –pipe2–> N –pipe3–> <out>

pipe1 - input pipe

Returns

list of the input pipes

Return type

Iterable[ZeroPipe]

property output_pipes(self) → Iterator[ZeroPipe][source]

It returns input pipes

Example:

<in> –pipe1–> N –pipe2–> N –pipe3–> <out> <–pipe4– N

pipe3 and pipe4 - output pipes

Returns

list of the output pipes

Return type

Iterable[ZeroPipe]

get_forward_pipes(self, pipe_or_node: Union[ZeroNode, ZeroPipe]) → Iterator[ZeroPipe][source]

Get all pipes that go after the pipe_or_node instance.

Example:

<in> –p1–> N1 –p2–> N2 –p3–> <out>

If p1 or N1 - target instance (pipe_or_node) then p2- forward pipe

Parameters

pipe_or_node (Union[ZeroNode, ZeroPipe]) – specify target pipe or node

Returns

all pipes after the pipe_or_node

Return type

Iterator[ZeroPipe]

get_backward_pipes(self, pipe_or_node: Union[ZeroNode, ZeroPipe]) → Iterator[ZeroPipe][source]

Get all pipes that go after the pipe_or_node instance.

Example:

<in> –p1–> N1 –p2–> N2 –p4–> <out>

If N1 or p2 - target instance (pipe_or_node) then p1 - backward pipe

Parameters

pipe_or_node (Union[ZeroNode, ZeroPipe]) – specify target pipe or node

Returns

all pipes before the pipe_or_node

Return type

Iterator[ZeroPipe]

get_pipes_map(self, reverse: bool = False, **kwargs) → Dict[str, Dict[str, Dict[str, Union[ZeroPipe, None]]]][source]

It returns pipes map like 3d array

Parameters

reverse (bool) – if true then 3d array -> map[“node_b_id”][“node_a_id”][“pipe_id”]

Returns

return 3d array -> map[“node_a_id”][“node_b_id”][“pipe_id”] = ZeroPipe()

Return type

Dict[str, Dict[str, Dict[str, ZeroPipe]]]

add_pipes(self, *pipes: Union[Iterable[Union[ZeroPipe, str]], Union[ZeroPipe, str]])[source]

It adds pipes to the ZeroNetwork instance

Parameters

pipes (Iterable[Union[ZeroPipe, str]) – list of args of the pipes (str or ZeroPipe instances)

remove_pipes(self, *pipes: Union[Iterable[Union['ZeroPipe', str]], Union['ZeroPipe', str]])[source]

It removes pipes from the Network

Parameters

pipes (Iterable[Union[ZeroPipe, str]]) – list of args of the pipes (str or ZeroPipe instances)

save(self, save_dependency: bool = True, **kwargs)[source]

Save current state to the repository.

Parameters
  • save_dependency (bool) – save related entities

  • save_dependency_depth (int) – depth of related entities recursion (-1 = infinity)

  • save_dependency_search_depth – depth of searching in the fields values (like dict).

__eq__(self, other: Any)[source]

Return self==value.

__ne__(self, other: Any)[source]

Return self!=value.

__add__(self, other: ZeroNetwork) → 'ZeroNetwork'[source]
__iadd__(self, other: ZeroNetwork) → 'ZeroNetwork'[source]
__sub__(self, other: ZeroNetwork) → 'ZeroNetwork'[source]
__isub__(self, other: ZeroNetwork) → 'ZeroNetwork'[source]
__and__(self, other: ZeroNetwork) → 'ZeroNetwork'[source]
__iand__(self, other: ZeroNetwork) → 'ZeroNetwork'[source]
__or__(self, other: ZeroNetwork) → 'ZeroNetwork'[source]
__ior__(self, other: ZeroNetwork) → 'ZeroNetwork'[source]