77class Compartment :
88 """
99 Compartments in ngcsimlib are container objects for storing the stateful
10- values of components. Compartments are
11- tracked globaly and are automatically linked to components and methods
12- during compiling to allow for stateful
13- mechanics to be run without the need for the class object. Compartments
14- also provide an entry and exit point for
15- values inside of components allowing for cables to be connected for
16- sending and receiving values.
10+ values of components. Compartments are tracked globally and are
11+ automatically linked to components and methods during compiling to allow
12+ for stateful mechanics to be run without the need for the class object.
13+ Compartments also provide an entry and exit point for values inside of
14+ components allowing for cables to be connected for sending and receiving
15+ values.
1716 """
1817
1918 @classmethod
@@ -31,19 +30,18 @@ def is_compartment(cls, obj):
3130 """
3231 return hasattr (obj , "_is_compartment" )
3332
34- def __init__ (self , initial_value = None , static = False , is_input = False , display_name = None , units = None ):
33+ def __init__ (self , initial_value = None , static = False , is_input = False ,
34+ display_name = None , units = None ):
3535 """
3636 Builds a compartment to be used inside a component. It is important
37- to note that building compartments
38- outside of components may cause unexpected behavior as components
39- interact with their compartments during
40- construction to finish initializing them.
37+ to note that building compartments outside of components may cause
38+ unexpected behavior as components interact with their compartments
39+ during construction to finish initializing them.
4140 Args:
4241 initial_value: The initial value of the compartment. As a general
43- practice it is a good idea to
44- provide a value that is similar to the values that will
45- normally be stored here, such as an array of
46- zeros of the correct length. (default: None)
42+ practice it is a good idea to provide a value that is similar to
43+ the values that will normally be stored here, such as an array of
44+ zeros of the correct length. (default: None)
4745
4846 static: a flag to lock a compartment to be static (default: False)
4947 """
@@ -105,10 +103,9 @@ def __str__(self):
105103 def __lshift__ (self , other ) -> None :
106104 """
107105 Overrides the left shift operation to be used for wiring compartments
108- into one another
109- if other is not an Operation it will create an overwrite operation
110- with other as the argument,
111- otherwise it will use the provided operation
106+ into one another if other is not an Operation it will create an
107+ overwrite operation with other as the argument, otherwise it will use
108+ the provided operation
112109
113110 Args:
114111 other: Either another component or an instance of BaseOp
@@ -136,9 +133,9 @@ def is_wired(self):
136133
137134 @property
138135 def display_name (self ):
139- return self ._display_name if self ._display_name is not None else self .name
136+ return self ._display_name if self ._display_name is not None else (
137+ self .name )
140138
141139 @property
142140 def units (self ):
143141 return self ._units if self ._units is not None else "dimensionless"
144-
0 commit comments