MCPcopy Create free account
hub / github.com/NTNU-IHB/PythonFMU / Real

Class Real

pythonfmu/variables.py:113–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111
112
113class Real(ScalarVariable):
114 def __init__(self, name: str, start: Optional[Any] = None, **kwargs):
115 super().__init__(name, **kwargs)
116 self.__attrs = {"start": start}
117
118 @property
119 def start(self) -> Optional[Any]:
120 return self.__attrs["start"]
121
122 @start.setter
123 def start(self, value: float):
124 self.__attrs["start"] = value
125
126 def to_xml(self) -> Element:
127 attrib = dict()
128 for key, value in self.__attrs.items():
129 if value is not None:
130 # In order to not loose precision, a number of this type should be
131 # stored on an XML file with at least 16 significant digits
132 attrib[key] = f"{value:.16g}"
133 parent = super().to_xml()
134 SubElement(parent, "Real", attrib)
135
136 return parent
137
138
139class Integer(ScalarVariable):

Callers 8

__init__Method · 0.90
__init__Method · 0.90
test_Real_constructorFunction · 0.90
test_Real_to_xmlFunction · 0.90
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by 2

test_Real_constructorFunction · 0.72
test_Real_to_xmlFunction · 0.72