pythonfmu3 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pythonfmu3/_version.py +1 -1
- pythonfmu3/pythonfmu-export/src/pythonfmu/PySlaveInstance.cpp +2 -1
- pythonfmu3/resources/binaries/x86_64-linux/libpythonfmu-export.so +0 -0
- pythonfmu3/resources/binaries/x86_64-windows/pythonfmu-export.dll +0 -0
- pythonfmu3/tests/test_variables.py +22 -3
- pythonfmu3/variables.py +9 -1
- {pythonfmu3-0.2.0.dist-info → pythonfmu3-0.2.1.dist-info}/METADATA +1 -1
- {pythonfmu3-0.2.0.dist-info → pythonfmu3-0.2.1.dist-info}/RECORD +12 -12
- {pythonfmu3-0.2.0.dist-info → pythonfmu3-0.2.1.dist-info}/LICENSE +0 -0
- {pythonfmu3-0.2.0.dist-info → pythonfmu3-0.2.1.dist-info}/WHEEL +0 -0
- {pythonfmu3-0.2.0.dist-info → pythonfmu3-0.2.1.dist-info}/entry_points.txt +0 -0
- {pythonfmu3-0.2.0.dist-info → pythonfmu3-0.2.1.dist-info}/top_level.txt +0 -0
pythonfmu3/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.2.
|
|
1
|
+
__version__ = "0.2.1"
|
|
@@ -73,6 +73,7 @@ PySlaveInstance::PySlaveInstance(std::string instanceName, std::string resources
|
|
|
73
73
|
std::string moduleName = getline(resources_ + "/slavemodule.txt");
|
|
74
74
|
PyObject* pModule = PyImport_ImportModule(moduleName.c_str());
|
|
75
75
|
if (pModule == nullptr) {
|
|
76
|
+
PyErr_Print();
|
|
76
77
|
handle_py_exception("[ctor] PyImport_ImportModule", gilState);
|
|
77
78
|
}
|
|
78
79
|
|
|
@@ -732,7 +733,7 @@ namespace
|
|
|
732
733
|
}
|
|
733
734
|
return TRUE;
|
|
734
735
|
}
|
|
735
|
-
#elif defined(__linux__)
|
|
736
|
+
#elif defined(__linux__) || defined(__APPLE__)
|
|
736
737
|
__attribute__((destructor)) void onLibraryUnload()
|
|
737
738
|
{
|
|
738
739
|
finalizePythonInterpreter();
|
|
Binary file
|
|
Binary file
|
|
@@ -8,7 +8,7 @@ from xml.etree import ElementTree
|
|
|
8
8
|
|
|
9
9
|
from pythonfmu3 import Fmi3Slave
|
|
10
10
|
from pythonfmu3.enums import Fmi3Causality, Fmi3Initial, Fmi3Variability
|
|
11
|
-
from pythonfmu3.variables import Boolean, Int32, UInt64, Float64, ModelVariable, String, Dimension
|
|
11
|
+
from pythonfmu3.variables import flatten, Boolean, Int32, UInt64, Float64, ModelVariable, String, Dimension
|
|
12
12
|
|
|
13
13
|
from .utils import PY2FMI, UInt64ValType
|
|
14
14
|
|
|
@@ -303,14 +303,33 @@ def test_String_to_xml(name, start):
|
|
|
303
303
|
@pytest.mark.requirements("numpy")
|
|
304
304
|
@pytest.mark.parametrize("name,start,dims", [
|
|
305
305
|
("array1", [1.,2.,3.,4.], [4]),
|
|
306
|
-
("array2", [1.,2.,3.,4.], [2, 2])
|
|
306
|
+
("array2", [1.,2.,3.,4.], [2, 2])
|
|
307
307
|
])
|
|
308
308
|
def test_array_to_xml(name, start, dims):
|
|
309
309
|
r = Float64(name, start, dimensions=[Dimension(start=val) for val in dims])
|
|
310
310
|
xml = r.to_xml()
|
|
311
311
|
if start is not None:
|
|
312
|
-
assert xml.attrib['start'] == " ".join([f"{val:.16g}" for val in start])
|
|
312
|
+
assert xml.attrib['start'] == " ".join([f"{val:.16g}" for val in flatten(start)])
|
|
313
313
|
if dims is not None:
|
|
314
314
|
xml_dims = xml.findall('.//Dimension')
|
|
315
315
|
assert len(xml_dims) == len(dims)
|
|
316
316
|
assert [xml_dim.attrib['start'] for xml_dim in xml_dims] == dims
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
@pytest.mark.requirements("numpy")
|
|
320
|
+
@pytest.mark.parametrize("name,start,dims", [
|
|
321
|
+
("array1", [1.,2.,3.,4.], [4]),
|
|
322
|
+
("array2", [1.,2.,3.,4.], [2, 2])
|
|
323
|
+
])
|
|
324
|
+
def test_array_output_to_xml(name, start, dims):
|
|
325
|
+
import numpy as np
|
|
326
|
+
start = np.reshape(start, newshape=dims)
|
|
327
|
+
r = Float64(name, start, dimensions=[Dimension(start=val) for val in dims], causality=Fmi3Causality.output)
|
|
328
|
+
xml = r.to_xml()
|
|
329
|
+
print(xml, start)
|
|
330
|
+
if start is not None:
|
|
331
|
+
assert xml.attrib['start'] == " ".join([f"{val:.16g}" for val in flatten(start)])
|
|
332
|
+
if dims is not None:
|
|
333
|
+
xml_dims = xml.findall('.//Dimension')
|
|
334
|
+
assert len(xml_dims) == len(dims)
|
|
335
|
+
assert [xml_dim.attrib['start'] for xml_dim in xml_dims] == dims
|
pythonfmu3/variables.py
CHANGED
|
@@ -4,11 +4,19 @@ from enum import Enum
|
|
|
4
4
|
import importlib
|
|
5
5
|
from typing import Any, Optional, List
|
|
6
6
|
from xml.etree.ElementTree import Element, SubElement
|
|
7
|
+
from collections.abc import Iterable
|
|
7
8
|
from collections import ChainMap
|
|
8
9
|
from functools import reduce
|
|
9
10
|
|
|
10
11
|
from .enums import Fmi3Causality, Fmi3Initial, Fmi3Variability
|
|
11
12
|
|
|
13
|
+
def flatten(lst):
|
|
14
|
+
for item in lst:
|
|
15
|
+
if isinstance(item, Iterable) and not isinstance(item, (str, bytes)):
|
|
16
|
+
yield from flatten(item)
|
|
17
|
+
else:
|
|
18
|
+
yield item
|
|
19
|
+
|
|
12
20
|
def check_numpy():
|
|
13
21
|
try:
|
|
14
22
|
importlib.import_module('numpy')
|
|
@@ -210,7 +218,7 @@ class Float64(ModelVariable):
|
|
|
210
218
|
# stored on an XML file with at least 16 significant digits
|
|
211
219
|
output = ""
|
|
212
220
|
if len(self.dimensions) > 0:
|
|
213
|
-
output = " ".join([f"{val:.16g}" for val in value])
|
|
221
|
+
output = " ".join([f"{val:.16g}" for val in flatten(value)])
|
|
214
222
|
else:
|
|
215
223
|
output = f"{value:.16g}"
|
|
216
224
|
attrib[key] = output
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
pythonfmu3/__init__.py,sha256=oN-2oXyCFwq0gvL2IEf5QvwIXBXZgsSBwAJw7LZ9vzc,424
|
|
2
2
|
pythonfmu3/__main__.py,sha256=gC1T8x2d02hhqshyNQGSS70SyCk-3I3t8zPqoRo2Xd8,1543
|
|
3
|
-
pythonfmu3/_version.py,sha256=
|
|
3
|
+
pythonfmu3/_version.py,sha256=HfjVOrpTnmZ-xVFCYSVmX50EXaBQeJteUHG-PD6iQs8,22
|
|
4
4
|
pythonfmu3/builder.py,sha256=d_nTRWKohZrZsMbTmxiYJzszzVBp-CRisV_y_OVyW6U,9779
|
|
5
5
|
pythonfmu3/default_experiment.py,sha256=FJ0l0FpU7pT4Pox2RiA2y-Cb_e7DE2XlbWKySRYQaVk,293
|
|
6
6
|
pythonfmu3/deploy.py,sha256=eqFWVxZUkJCLvmq1-GuMNjn2j0VCGoaXPhRWrCk2Vxg,3741
|
|
@@ -10,7 +10,7 @@ pythonfmu3/logmsg.py,sha256=0wn11GLwq0LLWqyC2ktLRjQFWlpj07wWliZ8rUHx1gg,359
|
|
|
10
10
|
pythonfmu3/osutil.py,sha256=1qN6qudN4zCupZwc15pzp52WObkqi6jGy9a-MehNt9Q,656
|
|
11
11
|
pythonfmu3/unit.py,sha256=SjOaywb5lVQbAO_iLjc_7Ly3nYrmAvIW2_hAGt12UFU,1475
|
|
12
12
|
pythonfmu3/variable_types.py,sha256=Q0D4wlGi3i3zE5UsmGJEpNh7SV_W8mn_8p_WIkwrLQA,2881
|
|
13
|
-
pythonfmu3/variables.py,sha256=
|
|
13
|
+
pythonfmu3/variables.py,sha256=6el55sAn8miVqPeUY-Q3GEw_pt6c46p7obg6G2UjyeA,12143
|
|
14
14
|
pythonfmu3/pythonfmu-export/.clang-format,sha256=ApbsHWYwilCXJ1iBux4nqOjLkaqgbGLsVrc_U3hX7WI,944
|
|
15
15
|
pythonfmu3/pythonfmu-export/CMakeLists.txt,sha256=p0-4Xh_sAaOI9AVb8lsUsMxJPc6bg9b_6CF6NJt5FHE,1847
|
|
16
16
|
pythonfmu3/pythonfmu-export/build_unix.sh,sha256=I5RrF2O6y0hRG_SN4ExKN_CCFYaa2l-ngKzqmBXnHmA,73
|
|
@@ -24,11 +24,11 @@ pythonfmu3/pythonfmu-export/src/fmi/fmi3FunctionTypes.h,sha256=Tk1WY0nAYBGiOAQ8z
|
|
|
24
24
|
pythonfmu3/pythonfmu-export/src/fmi/fmi3Functions.h,sha256=NsHuclp20wcuUInYf-91UXZbljTeu2cPXENqNEORdgU,16262
|
|
25
25
|
pythonfmu3/pythonfmu-export/src/fmi/fmi3PlatformTypes.h,sha256=ZCQLJgSbRGrMsBiQ4auaYCY4J3Hck6g3t1iZp5NEguw,4251
|
|
26
26
|
pythonfmu3/pythonfmu-export/src/pythonfmu/IPyState.hpp,sha256=GLiOjhKLDVEICersnqVwezwEshbxfdh_cyMxBJGFbu8,456
|
|
27
|
-
pythonfmu3/pythonfmu-export/src/pythonfmu/PySlaveInstance.cpp,sha256=
|
|
27
|
+
pythonfmu3/pythonfmu-export/src/pythonfmu/PySlaveInstance.cpp,sha256=WShZMdZExWWG86kFPh89mATYK4tVn38JdHV6c-fZ0_A,25411
|
|
28
28
|
pythonfmu3/pythonfmu-export/src/pythonfmu/PySlaveInstance.hpp,sha256=T-epGp68SjhDv-JupxUe2ZgnV8unU4htc-PUBokjWm4,4239
|
|
29
29
|
pythonfmu3/pythonfmu-export/src/pythonfmu/PyState.hpp,sha256=CjFEIrZu8b1jxQAIgfI_o36hyItW_SdQ5VSkImf7JNs,2977
|
|
30
|
-
pythonfmu3/resources/binaries/x86_64-linux/libpythonfmu-export.so,sha256=
|
|
31
|
-
pythonfmu3/resources/binaries/x86_64-windows/pythonfmu-export.dll,sha256=
|
|
30
|
+
pythonfmu3/resources/binaries/x86_64-linux/libpythonfmu-export.so,sha256=H-9BRLDmS-TfSGi6lOYvMIYEI3_tTcsBBuMMUYWt-IA,365288
|
|
31
|
+
pythonfmu3/resources/binaries/x86_64-windows/pythonfmu-export.dll,sha256=IFUevR81xjzf5silpT0Qbz4ybMCtktIOu9Z3jBGTpoE,431104
|
|
32
32
|
pythonfmu3/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
33
|
pythonfmu3/tests/conftest.py,sha256=B6XxTnBdeF_tEJ3w2DlfPKUfvlk-oULgIhQtXkgOJIc,171
|
|
34
34
|
pythonfmu3/tests/test_builder.py,sha256=GrD4ziin3RLOe_36rBQCMnKrSkhc3IqnxE1a6kCFPok,6842
|
|
@@ -37,7 +37,7 @@ pythonfmu3/tests/test_fmi3slave.py,sha256=1uwTdfiFZNmU0yzIdC30kAuu95xsZSTMA9CGk_
|
|
|
37
37
|
pythonfmu3/tests/test_integration.py,sha256=zA3iJ4rI2cKEE8mDsAmcVuwNWlJzhonV8Wxz92hzEac,10387
|
|
38
38
|
pythonfmu3/tests/test_logger.py,sha256=OcHQhxUtNBPH-0zdmheC4I9OWz1yu48W8MYDshNVkf8,5765
|
|
39
39
|
pythonfmu3/tests/test_multiple_fmus.py,sha256=-sthCm2YUZiRkdfvpLQNgquPBForUKQ7HGqfFBdrRas,3942
|
|
40
|
-
pythonfmu3/tests/test_variables.py,sha256=
|
|
40
|
+
pythonfmu3/tests/test_variables.py,sha256=avy1mzVOBmoVPrxLOLZy5stgKy415CPtTxrLdbSkyHU,10352
|
|
41
41
|
pythonfmu3/tests/utils.py,sha256=WusWSUGoBPenZL-FAKQlzaHN2aYXiznZM2fwCjoldwY,301
|
|
42
42
|
pythonfmu3/tests/data/csvdemo.csv,sha256=TiTUyzHyjQNXM4eXI33oJipc7w9_PJ8aMejRmwc52Xw,256
|
|
43
43
|
pythonfmu3/tests/data/hello.txt,sha256=wFNeS-K3n_2TKRMFQ2v4iTFOSj-uwF7P_Lt98xrZ5Ro,12
|
|
@@ -46,9 +46,9 @@ pythonfmu3/tests/slaves/localmodule.py,sha256=-q5Lmh2I88MG7nLTscms0n5xhHLkUDed1I
|
|
|
46
46
|
pythonfmu3/tests/slaves/pythonslave.py,sha256=uzrTQmfk0QBalxNTviGMZNph_YgVmcbxPqKgX5rSvXg,2172
|
|
47
47
|
pythonfmu3/tests/slaves/pythonslave_read_file.py,sha256=t2sDaZSr2veD91gdqCO9W9CN-AN3TyXABXXfV9Rt0Xs,791
|
|
48
48
|
pythonfmu3/tests/slaves/slavewithdep.py,sha256=hHDFB0dw8wkHiGzxeAVbz9O5LR6ghsFeONgRFdiK_t0,812
|
|
49
|
-
pythonfmu3-0.2.
|
|
50
|
-
pythonfmu3-0.2.
|
|
51
|
-
pythonfmu3-0.2.
|
|
52
|
-
pythonfmu3-0.2.
|
|
53
|
-
pythonfmu3-0.2.
|
|
54
|
-
pythonfmu3-0.2.
|
|
49
|
+
pythonfmu3-0.2.1.dist-info/LICENSE,sha256=RL2018BU2DKcTi8Eb4ODF-XF3wnr7SDKvMP5S49x4rQ,1188
|
|
50
|
+
pythonfmu3-0.2.1.dist-info/METADATA,sha256=zH3gg6qM81thMX4mmzFqVxCoAnRuDLtj1-wZwoFTuqA,7585
|
|
51
|
+
pythonfmu3-0.2.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
52
|
+
pythonfmu3-0.2.1.dist-info/entry_points.txt,sha256=GgkWYs0DKGHLcijMEYZGkhkHOK2RVUpjGwvl1fwyDwQ,60
|
|
53
|
+
pythonfmu3-0.2.1.dist-info/top_level.txt,sha256=6ne7bh_cME1hepxCx1BG8N5QVhVAufrp7LLok6vq7nE,11
|
|
54
|
+
pythonfmu3-0.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|