PySimultan 0.2.10__py3-none-any.whl → 0.3.1__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- {PySimultan-0.2.10.dist-info → PySimultan-0.3.1.dist-info}/METADATA +1 -1
- {PySimultan-0.2.10.dist-info → PySimultan-0.3.1.dist-info}/RECORD +9 -9
- PySimultan2/default_types.py +11 -5
- PySimultan2/object_mapper.py +29 -22
- PySimultan2/simultan_object.py +9 -0
- PySimultan2/utils.py +24 -5
- {PySimultan-0.2.10.dist-info → PySimultan-0.3.1.dist-info}/LICENSE.txt +0 -0
- {PySimultan-0.2.10.dist-info → PySimultan-0.3.1.dist-info}/WHEEL +0 -0
- {PySimultan-0.2.10.dist-info → PySimultan-0.3.1.dist-info}/top_level.txt +0 -0
@@ -1,13 +1,13 @@
|
|
1
1
|
PySimultan2/__init__.py,sha256=X10eSCNtac3CG28w7Ogo1csNalhapO9V4oVSIucc0Kw,1121
|
2
2
|
PySimultan2/config.py,sha256=Bazt2vDSEga_cFEIPWcAYBsj3TUN5jgtob8TtUvGm5E,1523
|
3
3
|
PySimultan2/data_model.py,sha256=2Qq_JyUxtDgsIt3p5hIXIqNy7eAtvn-6Of_Wzb9AWoE,28004
|
4
|
-
PySimultan2/default_types.py,sha256=
|
4
|
+
PySimultan2/default_types.py,sha256=E4aS3NuLl0mG5vBJv0saxbBFWk1s4eSg21cl4bcNAH8,22880
|
5
5
|
PySimultan2/files.py,sha256=q6A5KTqU1nCwh0W0Qf3Se7qcvhGiDAWza2v-X-rt6E4,12473
|
6
6
|
PySimultan2/multi_values.py,sha256=ZFXlTLuZo32x7_7diYAp2XEjp5uwgHLgNOzN7v74-5I,13650
|
7
|
-
PySimultan2/object_mapper.py,sha256=
|
8
|
-
PySimultan2/simultan_object.py,sha256=
|
7
|
+
PySimultan2/object_mapper.py,sha256=cvw0gJk3NzsSkN2UNd7nRxhBkTe7TYddmHwxW7VpIHg,8973
|
8
|
+
PySimultan2/simultan_object.py,sha256=PWpveGPFi1nlcHSK8vT_3lyEoa27eBY6ZpKAtgR-KGg,16215
|
9
9
|
PySimultan2/taxonomy_maps.py,sha256=qgKM0CdwwgLCFj-ivzY38VaCpE_eCPKyCiBaTBazpBk,7509
|
10
|
-
PySimultan2/utils.py,sha256=
|
10
|
+
PySimultan2/utils.py,sha256=U3Eru2uQbDCxraFbbbUO1wmVRxLXmo4lFksVcJcrtmg,62818
|
11
11
|
PySimultan2/geometry/__init__.py,sha256=nJolTD1i5J8qUkOQa-r3D20aq3Co3sN31Xc0n4wJpJo,248
|
12
12
|
PySimultan2/geometry/geometry_base.py,sha256=IQQPVxkgIdBsFJp8rPSCNiCiKO7TxkVWy-XmE8GjDbE,23367
|
13
13
|
PySimultan2/geometry/utils.py,sha256=K_3HnqPMAlJkOh01oqjspeqsLrooG9NwIQKWf14IJ48,8513
|
@@ -75,8 +75,8 @@ PySimultan2/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
|
|
75
75
|
PySimultan2/resources/assimp.dll,sha256=HwfDwXqoPDTFRyoQpA3qmgZoUdFtziJkV5fNtktEZEU,6081536
|
76
76
|
PySimultan2/resources/defaultsettings.xml,sha256=s6Tk1tubLz5UYqXZWpD42EDHzedemRY1nEneoIVcUfg,392
|
77
77
|
PySimultan2/resources/setup.bat,sha256=fjvvYfVM6TalS-QTSiKAbAId5nTsk8kGGo06ba-wWaY,32
|
78
|
-
PySimultan-0.
|
79
|
-
PySimultan-0.
|
80
|
-
PySimultan-0.
|
81
|
-
PySimultan-0.
|
82
|
-
PySimultan-0.
|
78
|
+
PySimultan-0.3.1.dist-info/LICENSE.txt,sha256=htoPAa6uRjSKPD1GUZXcHOzN55956HdppkuNoEsqR0E,1023
|
79
|
+
PySimultan-0.3.1.dist-info/METADATA,sha256=sikNq1pLMe2i0Gx3X1RFSofB9Rxae3u-PL0AJgefSto,1990
|
80
|
+
PySimultan-0.3.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
81
|
+
PySimultan-0.3.1.dist-info/top_level.txt,sha256=pbE6SbdKIEEK4vaDNmmdRTj0vesrjgRXGow8QWMTXvk,12
|
82
|
+
PySimultan-0.3.1.dist-info/RECORD,,
|
PySimultan2/default_types.py
CHANGED
@@ -97,7 +97,7 @@ class ComponentList(SimultanObject):
|
|
97
97
|
|
98
98
|
@property
|
99
99
|
def ref_components(self):
|
100
|
-
return [x.Target for x in self._wrapped_obj.ReferencedComponents.Items]
|
100
|
+
return [x.Target for x in self._wrapped_obj.ReferencedComponents.Items if x.Target is not None]
|
101
101
|
|
102
102
|
@property
|
103
103
|
def data(self) -> List[SimultanObject]:
|
@@ -109,7 +109,7 @@ class ComponentList(SimultanObject):
|
|
109
109
|
all_components = [*components, *ref_components]
|
110
110
|
|
111
111
|
slots = [*[x.Slot for x in self._wrapped_obj.Components.Items],
|
112
|
-
*[x.Slot for x in self._wrapped_obj.ReferencedComponents.Items]]
|
112
|
+
*[x.Slot for x in self._wrapped_obj.ReferencedComponents.Items if x.Target is not None]]
|
113
113
|
|
114
114
|
try:
|
115
115
|
indices = sort_slots(slots)
|
@@ -433,6 +433,12 @@ class ComponentDictionary(SimultanObject):
|
|
433
433
|
setter_fcn = self.type_setter_fcn_lookup_dict.get(type(value), set_property_to_unknown_type)
|
434
434
|
|
435
435
|
setter_fcn(*fcn_arg_list)
|
436
|
+
item = self.__getitem__(key, check_dict=False)
|
437
|
+
|
438
|
+
# self._object_mapper.create_python_object(self._wrapped_obj)
|
439
|
+
#
|
440
|
+
# if isinstance(value, ):
|
441
|
+
|
436
442
|
self._dict[key] = self.__getitem__(key, check_dict=False)
|
437
443
|
|
438
444
|
def __delitem__(self, key):
|
@@ -460,9 +466,9 @@ class ComponentDictionary(SimultanObject):
|
|
460
466
|
data_model=self._data_model,
|
461
467
|
object_mapper=self._object_mapper)
|
462
468
|
for component in self._wrapped_obj.Components.Items:
|
463
|
-
comp_dict[component.
|
464
|
-
|
465
|
-
|
469
|
+
comp_dict[component.Slot.SlotBase.Target.Key] = get_obj_value(component.Component,
|
470
|
+
data_model=self._data_model,
|
471
|
+
object_mapper=self._object_mapper)
|
466
472
|
for ref_component in self._wrapped_obj.ReferencedComponents.Items:
|
467
473
|
comp_dict[ref_component.Slot.SlotBase.Target.Name] = get_obj_value(ref_component.Target,
|
468
474
|
data_model=self._data_model,
|
PySimultan2/object_mapper.py
CHANGED
@@ -12,6 +12,7 @@ from .simultan_object import SimultanObject
|
|
12
12
|
from .geometry.utils import create_python_geometry
|
13
13
|
|
14
14
|
from SIMULTAN.Data.Geometry import (Layer, Vertex, Edge, PEdge, Face, Volume, EdgeLoop)
|
15
|
+
from SIMULTAN.Data.Components import SimComponent
|
15
16
|
from .geometry.geometry_base import (SimultanLayer, SimultanVertex, SimultanEdge, SimultanEdgeLoop, SimultanFace,
|
16
17
|
SimultanVolume)
|
17
18
|
|
@@ -94,31 +95,37 @@ class PythonMapper(object):
|
|
94
95
|
if data_model is None:
|
95
96
|
data_model = list(data_models)[0]
|
96
97
|
|
98
|
+
if create_all:
|
99
|
+
new_component_list = set()
|
100
|
+
|
101
|
+
def get_subcomponents(sim_component: Union[SimComponent, SimultanObject]):
|
102
|
+
print(sim_component.Id)
|
103
|
+
new_subcomponents = set()
|
104
|
+
if isinstance(sim_component, SimultanObject):
|
105
|
+
sim_component = sim_component._wrapped_obj
|
106
|
+
|
107
|
+
if sim_component in new_component_list:
|
108
|
+
return
|
109
|
+
else:
|
110
|
+
new_component_list.add(sim_component)
|
111
|
+
|
112
|
+
for sub_component in sim_component.Components.Items:
|
113
|
+
new_subcomponents.add(sub_component.Component)
|
114
|
+
for ref_component in sim_component.ReferencedComponents.Items:
|
115
|
+
new_subcomponents.add(ref_component.Target)
|
116
|
+
|
117
|
+
for new_subcomponent in new_subcomponents:
|
118
|
+
get_subcomponents(new_subcomponent)
|
119
|
+
|
120
|
+
new_component_list.update(new_subcomponents)
|
121
|
+
|
122
|
+
for component in component_list:
|
123
|
+
get_subcomponents(component)
|
124
|
+
component_list = list(new_component_list)
|
125
|
+
|
97
126
|
for component in component_list:
|
98
127
|
typed_object = self.create_python_object(component, data_model=data_model)
|
99
128
|
typed_data.append(typed_object)
|
100
|
-
if create_all:
|
101
|
-
|
102
|
-
def get_content(typed_object):
|
103
|
-
if isinstance(typed_object, SimultanObject):
|
104
|
-
for content in typed_object.__class__._taxonomy_map.content:
|
105
|
-
val = getattr(typed_object, content.property_name)
|
106
|
-
if isinstance(val, (SimultanObject, ComponentList, ComponentDictionary)):
|
107
|
-
typed_data.append(val)
|
108
|
-
get_content(val)
|
109
|
-
elif isinstance(typed_object, ComponentList):
|
110
|
-
for item in typed_object:
|
111
|
-
if isinstance(item, (SimultanObject, ComponentList, ComponentDictionary)):
|
112
|
-
typed_data.append(item)
|
113
|
-
get_content(item)
|
114
|
-
elif isinstance(typed_object, ComponentDictionary):
|
115
|
-
for item in typed_object.values():
|
116
|
-
if isinstance(item, (SimultanObject, ComponentList, ComponentDictionary)):
|
117
|
-
typed_data.append(item)
|
118
|
-
get_content(item)
|
119
|
-
|
120
|
-
get_content(typed_object)
|
121
|
-
|
122
129
|
return typed_data
|
123
130
|
|
124
131
|
# @lru_cache(maxsize=None)
|
PySimultan2/simultan_object.py
CHANGED
@@ -136,6 +136,15 @@ class SimultanObject(object, metaclass=MetaMock):
|
|
136
136
|
return instance
|
137
137
|
|
138
138
|
def __init__(self, *args, **kwargs):
|
139
|
+
"""
|
140
|
+
Initialize the SimultanObject. This method is only called if the object is initialized the first time without a
|
141
|
+
wrapped_obj. If a wrapped_obj is defined, the __new__ method is called and the object can be initialized with
|
142
|
+
the __load_init__ method.
|
143
|
+
|
144
|
+
:param args:
|
145
|
+
:param kwargs:
|
146
|
+
"""
|
147
|
+
|
139
148
|
self._wrapped_obj: Union[SimComponent, None] = kwargs.get('wrapped_obj', None)
|
140
149
|
self.__obj_init__ = kwargs.get('__obj_init__', False)
|
141
150
|
self._data_model_id = kwargs.get('data_model_id', None)
|
PySimultan2/utils.py
CHANGED
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
2
2
|
|
3
3
|
from . import config
|
4
4
|
from enum import Enum
|
5
|
+
from weakref import WeakSet
|
5
6
|
from functools import lru_cache
|
6
7
|
import numpy as np
|
7
8
|
import pandas as pd
|
@@ -45,6 +46,9 @@ class UnresolvedObject(object):
|
|
45
46
|
def resolve(self):
|
46
47
|
return self.cls._cls_instances_dict[self.wrapped_obj.Id]
|
47
48
|
|
49
|
+
def __getattr__(self, item):
|
50
|
+
return getattr(self.wrapped_obj, item)
|
51
|
+
|
48
52
|
|
49
53
|
class CircularReferenceResolver(object):
|
50
54
|
|
@@ -91,11 +95,25 @@ def create_python_object(wrapped_obj: SimComponent, cls: Type[SimultanObject], *
|
|
91
95
|
prop_name=content.text_or_key,
|
92
96
|
object_mapper=kwargs.get('object_mapper', None),
|
93
97
|
)
|
98
|
+
|
94
99
|
kwargs['name'] = wrapped_obj.Name
|
95
100
|
kwargs['__obj_init__'] = True
|
96
|
-
obj = cls(wrapped_obj=wrapped_obj, *args, **kwargs)
|
97
|
-
obj.__obj_init__ = False
|
98
101
|
|
102
|
+
obj = cls.__new__(cls)
|
103
|
+
obj._wrapped_obj = wrapped_obj
|
104
|
+
obj._data_model = kwargs.get('data_model', None)
|
105
|
+
obj._object_mapper = kwargs.get('object_mapper', None)
|
106
|
+
|
107
|
+
if "_cls_instances" not in cls.__dict__:
|
108
|
+
cls._cls_instances = WeakSet()
|
109
|
+
try:
|
110
|
+
cls._cls_instances.add(obj)
|
111
|
+
except Exception as e:
|
112
|
+
logger.error(f'Error adding instance {obj} to _cls_instances: {e}')
|
113
|
+
|
114
|
+
if hasattr(cls, '__load_init__'):
|
115
|
+
obj.__init__(*args, **kwargs)
|
116
|
+
#
|
99
117
|
circ_ref_resolver.unresolved_objects.pop(wrapped_obj.Id)
|
100
118
|
|
101
119
|
return obj
|
@@ -380,13 +398,15 @@ def add_sub_component(comp: SimComponent,
|
|
380
398
|
sub_comp.Slots.InsertItem(0, slot)
|
381
399
|
|
382
400
|
if slot_extension is None:
|
383
|
-
new_slot = comp.Components.FindAvailableSlot(slot,
|
401
|
+
new_slot = comp.Components.FindAvailableSlot(slot.Target if isinstance(slot,
|
402
|
+
SimTaxonomyEntryReference)
|
403
|
+
else slot, "{0}")
|
384
404
|
else:
|
385
405
|
new_slot = SimSlot(sub_comp.Slots[0].Target, str(slot_extension))
|
386
406
|
|
387
407
|
entry = SimChildComponentEntry(new_slot, sub_comp)
|
388
408
|
if entry not in comp.Components.Items:
|
389
|
-
comp.Components.InsertItem(len(comp.Components.Items)
|
409
|
+
comp.Components.InsertItem(len(comp.Components.Items), entry)
|
390
410
|
return True
|
391
411
|
|
392
412
|
|
@@ -1281,7 +1301,6 @@ def add_properties(prop_name: str,
|
|
1281
1301
|
np.ndarray: set_property_to_value_field,
|
1282
1302
|
pd.DataFrame: set_property_to_value_field}
|
1283
1303
|
|
1284
|
-
# @lru_cache()
|
1285
1304
|
def getx(self):
|
1286
1305
|
return get_property(component=self,
|
1287
1306
|
prop_name=content.text_or_key,
|
File without changes
|
File without changes
|
File without changes
|