Skip to content

Commit faf5914

Browse files
committed
Added documentation and update the map_valve function to take in the valve type information optionally
1 parent d547e67 commit faf5914

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

parchmint/device.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from networkx.algorithms import components
44
from parchmint.layer import Layer
55
import networkx as nx
6-
from typing import Dict, Optional, List
6+
from typing import Dict, Optional, List, overload
77
from parchmint.component import Component
88
from parchmint.connection import Connection
99
from parchmint.params import Params
@@ -68,22 +68,53 @@ def __init__(self, json=None):
6868
self.parse_from_json(json)
6969
self.generate_network()
7070

71-
def map_valve(self, valve: Component, connection: Connection) -> None:
71+
def map_valve(
72+
self,
73+
valve: Component,
74+
connection: Connection,
75+
type_info: Optional[ValveType] = None,
76+
) -> None:
7277
"""Maps the valve to a connection in the device
7378
7479
Args:
7580
valve (Component): valve component
7681
connection (Connection): connection on which the valve is mapped
82+
type_info (Optional[ValveType]): Type informaiton of the valve
83+
7784
"""
7885
self._valve_map[valve] = connection
86+
if type_info is not None:
87+
self.update_valve_type(valve, type_info)
7988

8089
def get_valves(self) -> List[Component]:
90+
"""Returns the list of valves in the device
91+
92+
Returns:
93+
List[Component]: Valve Component Objects
94+
"""
8195
return list(self._valve_map.keys())
8296

8397
def get_valve_connection(self, valve: Component) -> Connection:
98+
"""Returns the connection associated with the valve object
99+
100+
Args:
101+
valve (Component): Valve object for which we are finding the connection
102+
103+
Returns:
104+
Connection: connection object on which the valve is placed
105+
"""
84106
return self._valve_map[valve]
85107

86108
def update_valve_type(self, valve: Component, type_info: ValveType) -> None:
109+
"""Updates the type of the valve to normally closed or normally open
110+
111+
Args:
112+
valve (Component): Valve object we want to update
113+
type_info (ValveType): Valve Type
114+
115+
Raises:
116+
KeyError: Raises the error if the valve object is not mapped as a valve in the device
117+
"""
87118
if valve in list(self._valve_map.keys()):
88119
self._valve_type_map[valve] = type_info
89120
else:

0 commit comments

Comments
 (0)