pythonfmu3 0.2.0__tar.gz → 0.2.1__tar.gz

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.
Files changed (63) hide show
  1. {pythonfmu3-0.2.0/pythonfmu3.egg-info → pythonfmu3-0.2.1}/PKG-INFO +1 -1
  2. pythonfmu3-0.2.1/pythonfmu3/_version.py +1 -0
  3. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/src/pythonfmu/PySlaveInstance.cpp +2 -1
  4. pythonfmu3-0.2.1/pythonfmu3/resources/binaries/x86_64-linux/libpythonfmu-export.so +0 -0
  5. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/resources/binaries/x86_64-windows/pythonfmu-export.dll +0 -0
  6. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/test_variables.py +22 -3
  7. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/variables.py +9 -1
  8. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1/pythonfmu3.egg-info}/PKG-INFO +1 -1
  9. pythonfmu3-0.2.0/pythonfmu3/_version.py +0 -1
  10. pythonfmu3-0.2.0/pythonfmu3/resources/binaries/x86_64-linux/libpythonfmu-export.so +0 -0
  11. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/LICENSE +0 -0
  12. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/MANIFEST.in +0 -0
  13. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/README.md +0 -0
  14. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/__init__.py +0 -0
  15. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/__main__.py +0 -0
  16. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/builder.py +0 -0
  17. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/default_experiment.py +0 -0
  18. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/deploy.py +0 -0
  19. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/enums.py +0 -0
  20. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/fmi3slave.py +0 -0
  21. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/logmsg.py +0 -0
  22. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/osutil.py +0 -0
  23. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/.clang-format +0 -0
  24. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/CMakeLists.txt +0 -0
  25. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/build_unix.sh +0 -0
  26. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/build_win.sh +0 -0
  27. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/src/CMakeLists.txt +0 -0
  28. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_common.hpp +0 -0
  29. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_cs.cpp +0 -0
  30. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_cs.hpp +0 -0
  31. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/src/cppfmu/fmi_functions.cpp +0 -0
  32. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/src/fmi/fmi3FunctionTypes.h +0 -0
  33. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/src/fmi/fmi3Functions.h +0 -0
  34. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/src/fmi/fmi3PlatformTypes.h +0 -0
  35. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/src/pythonfmu/IPyState.hpp +0 -0
  36. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/src/pythonfmu/PySlaveInstance.hpp +0 -0
  37. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/pythonfmu-export/src/pythonfmu/PyState.hpp +0 -0
  38. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/__init__.py +0 -0
  39. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/conftest.py +0 -0
  40. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/data/csvdemo.csv +0 -0
  41. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/data/hello.txt +0 -0
  42. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/slaves/PythonSlaveWithException.py +0 -0
  43. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/slaves/localmodule.py +0 -0
  44. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/slaves/pythonslave.py +0 -0
  45. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/slaves/pythonslave_read_file.py +0 -0
  46. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/slaves/slavewithdep.py +0 -0
  47. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/test_builder.py +0 -0
  48. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/test_deploy.py +0 -0
  49. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/test_fmi3slave.py +0 -0
  50. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/test_integration.py +0 -0
  51. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/test_logger.py +0 -0
  52. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/test_multiple_fmus.py +0 -0
  53. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/tests/utils.py +0 -0
  54. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/unit.py +0 -0
  55. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3/variable_types.py +0 -0
  56. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3.egg-info/SOURCES.txt +0 -0
  57. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3.egg-info/dependency_links.txt +0 -0
  58. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3.egg-info/entry_points.txt +0 -0
  59. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3.egg-info/not-zip-safe +0 -0
  60. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3.egg-info/requires.txt +0 -0
  61. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/pythonfmu3.egg-info/top_level.txt +0 -0
  62. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/setup.cfg +0 -0
  63. {pythonfmu3-0.2.0 → pythonfmu3-0.2.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pythonfmu3
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A lightweight framework that enables the packaging of Python3.x code as co-simulation FMUs.
5
5
  Home-page: https://github.com/stephensmith25/PythonFMU3
6
6
  Author: Stephen Smith
@@ -0,0 +1 @@
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();
@@ -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
@@ -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
  Metadata-Version: 2.2
2
2
  Name: pythonfmu3
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A lightweight framework that enables the packaging of Python3.x code as co-simulation FMUs.
5
5
  Home-page: https://github.com/stephensmith25/PythonFMU3
6
6
  Author: Stephen Smith
@@ -1 +0,0 @@
1
- __version__ = "0.2.0"
File without changes
File without changes
File without changes
File without changes
File without changes