Skip to content

Commit f9289c5

Browse files
committed
added compartment metadata
1 parent 087706e commit f9289c5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ngcsimlib/compartment.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def is_compartment(cls, obj):
3131
"""
3232
return hasattr(obj, "_is_compartment")
3333

34-
def __init__(self, initial_value=None, static=False, is_input=False):
34+
def __init__(self, initial_value=None, static=False, is_input=False, display_name=None, units=None):
3535
"""
3636
Builds a compartment to be used inside a component. It is important
3737
to note that building compartments
@@ -56,6 +56,8 @@ def __init__(self, initial_value=None, static=False, is_input=False):
5656
self.path = None
5757
self.is_input = is_input
5858
self._is_destination = False
59+
self._display_name = display_name
60+
self._units = units
5961

6062
def _setup(self, current_component, key):
6163
"""
@@ -131,3 +133,12 @@ def is_wired(self):
131133
return True
132134

133135
return self._is_destination
136+
137+
@property
138+
def display_name(self):
139+
return self._display_name if self._display_name is not None else self.name
140+
141+
@property
142+
def units(self):
143+
return self._units if self._units is not None else "dimensionless"
144+

0 commit comments

Comments
 (0)