ansys-pyensight-core 0.7.8__py3-none-any.whl → 0.7.9__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.
Potentially problematic release.
This version of ansys-pyensight-core might be problematic. Click here for more details.
- ansys/pyensight/core/dockerlauncher.py +52 -44
- ansys/pyensight/core/enscontext.py +17 -15
- ansys/pyensight/core/enshell_grpc.py +8 -8
- ansys/pyensight/core/ensight_grpc.py +37 -35
- ansys/pyensight/core/ensobj.py +4 -4
- ansys/pyensight/core/launch_ensight.py +2 -2
- ansys/pyensight/core/launcher.py +4 -4
- ansys/pyensight/core/listobj.py +18 -16
- ansys/pyensight/core/renderable.py +9 -8
- ansys/pyensight/core/session.py +33 -29
- ansys/pyensight/core/utils/export.py +9 -9
- ansys/pyensight/core/utils/omniverse_dsg_server.py +1 -0
- ansys/pyensight/core/utils/parts.py +50 -36
- ansys/pyensight/core/utils/query.py +41 -35
- ansys/pyensight/core/utils/variables.py +158 -139
- ansys/pyensight/core/utils/views.py +14 -14
- {ansys_pyensight_core-0.7.8.dist-info → ansys_pyensight_core-0.7.9.dist-info}/METADATA +2 -2
- ansys_pyensight_core-0.7.9.dist-info/RECORD +34 -0
- ansys_pyensight_core-0.7.8.dist-info/RECORD +0 -34
- {ansys_pyensight_core-0.7.8.dist-info → ansys_pyensight_core-0.7.9.dist-info}/LICENSE +0 -0
- {ansys_pyensight_core-0.7.8.dist-info → ansys_pyensight_core-0.7.9.dist-info}/WHEEL +0 -0
ansys/pyensight/core/listobj.py
CHANGED
|
@@ -107,12 +107,14 @@ class ensobjlist(List[T]): # noqa: N801
|
|
|
107
107
|
value_list = [value]
|
|
108
108
|
out_list: ensobjlist[Any] = ensobjlist(session=self._session)
|
|
109
109
|
for item in self:
|
|
110
|
-
if isinstance(item, ENSOBJ):
|
|
110
|
+
if isinstance(item, ENSOBJ): # pragma: no cover
|
|
111
111
|
try:
|
|
112
112
|
item_value = item.getattr(attr)
|
|
113
113
|
for check_value in value_list:
|
|
114
114
|
if wildcard == 2:
|
|
115
|
-
if fnmatch.fnmatch(
|
|
115
|
+
if fnmatch.fnmatch(
|
|
116
|
+
str(item_value), str(check_value)
|
|
117
|
+
): # pragma: no cover
|
|
116
118
|
out_list.append(item)
|
|
117
119
|
break
|
|
118
120
|
elif wildcard > 0:
|
|
@@ -123,14 +125,14 @@ class ensobjlist(List[T]): # noqa: N801
|
|
|
123
125
|
if item_value == check_value:
|
|
124
126
|
out_list.append(item)
|
|
125
127
|
break
|
|
126
|
-
except RuntimeError:
|
|
127
|
-
pass
|
|
128
|
+
except RuntimeError: # pragma: no cover
|
|
129
|
+
pass # pragma: no cover
|
|
128
130
|
if group:
|
|
129
131
|
# This is a bit of a hack, but the find() method generates a local list of
|
|
130
132
|
# proxy objects. We want to put that in a group. We do that by running
|
|
131
133
|
# a script in EnSight that creates an empty group and then adds those
|
|
132
134
|
# children to the group. The output becomes the remote referenced ENS_GROUP.
|
|
133
|
-
if self._session is not None:
|
|
135
|
+
if self._session is not None: # pragma: no cover
|
|
134
136
|
ens_group_cmd = "ensight.objs.core.VPORTS.find('__unknown__', group=1)"
|
|
135
137
|
ens_group = self._session.cmd(ens_group_cmd)
|
|
136
138
|
ens_group.addchild(out_list)
|
|
@@ -163,14 +165,14 @@ class ensobjlist(List[T]): # noqa: N801
|
|
|
163
165
|
"""
|
|
164
166
|
session = None
|
|
165
167
|
objid_list = [x.__OBJID__ for x in self if isinstance(x, ENSOBJ)]
|
|
166
|
-
for item in self:
|
|
167
|
-
if hasattr(item, "_session"):
|
|
168
|
+
for item in self: # pragma: no cover
|
|
169
|
+
if hasattr(item, "_session"): # pragma: no cover
|
|
168
170
|
session = item._session
|
|
169
171
|
break
|
|
170
|
-
if session:
|
|
172
|
+
if session: # pragma: no cover
|
|
171
173
|
msg = f"ensight.objs.ensobjlist(ensight.objs.wrap_id(x) for x in {objid_list}).set_attr({attr.__repr__()}, {value.__repr__()})"
|
|
172
174
|
return session.cmd(msg)
|
|
173
|
-
return 0
|
|
175
|
+
return 0 # pragma: no cover
|
|
174
176
|
|
|
175
177
|
def get_attr(self, attr: Any, default: Optional[Any] = None):
|
|
176
178
|
"""Query a specific attribute for all ENSOBJ objects in the list
|
|
@@ -199,20 +201,20 @@ class ensobjlist(List[T]): # noqa: N801
|
|
|
199
201
|
"""
|
|
200
202
|
session = None
|
|
201
203
|
objid_list = [x.__OBJID__ for x in self if isinstance(x, ENSOBJ)]
|
|
202
|
-
for item in self:
|
|
203
|
-
if hasattr(item, "_session"):
|
|
204
|
+
for item in self: # pragma: no cover
|
|
205
|
+
if hasattr(item, "_session"): # pragma: no cover
|
|
204
206
|
session = item._session
|
|
205
207
|
break
|
|
206
208
|
value = None
|
|
207
|
-
if session:
|
|
208
|
-
if default:
|
|
209
|
-
msg = f"ensight.objs.ensobjlist(ensight.objs.wrap_id(x) for x in {objid_list}).get_attr({attr.__repr__()}, {default.__repr__()})"
|
|
209
|
+
if session: # pragma: no cover
|
|
210
|
+
if default: # pragma: no cover
|
|
211
|
+
msg = f"ensight.objs.ensobjlist(ensight.objs.wrap_id(x) for x in {objid_list}).get_attr({attr.__repr__()}, {default.__repr__()})" # pragma: no cover
|
|
210
212
|
else:
|
|
211
213
|
msg = f"ensight.objs.ensobjlist(ensight.objs.wrap_id(x) for x in {objid_list}).get_attr({attr.__repr__()})"
|
|
212
214
|
value = session.cmd(msg)
|
|
213
|
-
if value:
|
|
215
|
+
if value: # pragma: no cover
|
|
214
216
|
return value
|
|
215
|
-
return [default] * len(objid_list)
|
|
217
|
+
return [default] * len(objid_list) # pragma: no cover
|
|
216
218
|
|
|
217
219
|
@overload
|
|
218
220
|
def __getitem__(self, index: SupportsIndex) -> T:
|
|
@@ -563,8 +563,9 @@ class RenderableVNC(Renderable):
|
|
|
563
563
|
"""
|
|
564
564
|
optional_query = self._get_query_parameters_str()
|
|
565
565
|
version = _get_ansysnexus_version(self._session._cei_suffix)
|
|
566
|
-
if int(self._session._cei_suffix) <
|
|
567
|
-
|
|
566
|
+
if int(self._session._cei_suffix) < 242: # pragma: no cover
|
|
567
|
+
version = ""
|
|
568
|
+
self._update_2023R2_or_less() # pragma: no cover
|
|
568
569
|
else:
|
|
569
570
|
html = (
|
|
570
571
|
f"<script src='/ansys{version}/nexus/viewer-loader.js{optional_query}'></script>\n"
|
|
@@ -577,8 +578,8 @@ class RenderableVNC(Renderable):
|
|
|
577
578
|
)
|
|
578
579
|
|
|
579
580
|
query_args = ""
|
|
580
|
-
if self._using_proxy and optional_query:
|
|
581
|
-
query_args = f', "extra_query_args":"{optional_query[1:]}"'
|
|
581
|
+
if self._using_proxy and optional_query: # pragma: no cover
|
|
582
|
+
query_args = f', "extra_query_args":"{optional_query[1:]}"' # pragma: no cover
|
|
582
583
|
|
|
583
584
|
attributes = ' renderer="envnc"'
|
|
584
585
|
attributes += ' ui="simple"'
|
|
@@ -693,11 +694,11 @@ class RenderableEVSN(Renderable):
|
|
|
693
694
|
f'"ws":"{self._http_protocol}://{self._session.html_hostname}:{self._session.ws_port}"'
|
|
694
695
|
)
|
|
695
696
|
secrets = f'"security_token":"{self._session.secret_key}"'
|
|
696
|
-
if not self._using_proxy or optional_query == "":
|
|
697
|
+
if not self._using_proxy or optional_query == "": # pragma: no cover
|
|
697
698
|
attributes += f" renderer_options='{{ {http_uri}, {ws_uri}, {secrets} }}'"
|
|
698
|
-
else:
|
|
699
|
-
query_args = f'"extra_query_args":"{optional_query[1:]}"'
|
|
700
|
-
attributes += f" renderer_options='{{ {http_uri}, {ws_uri}, {secrets}, {query_args} }}'"
|
|
699
|
+
else: # pragma: no cover
|
|
700
|
+
query_args = f'"extra_query_args":"{optional_query[1:]}"' # pragma: no cover
|
|
701
|
+
attributes += f" renderer_options='{{ {http_uri}, {ws_uri}, {secrets}, {query_args} }}'" # pragma: no cover
|
|
701
702
|
html += f"<ansys-nexus-viewer {attributes}></ansys-nexus-viewer>\n"
|
|
702
703
|
# refresh the remote HTML
|
|
703
704
|
self._save_remote_html_page(html)
|
ansys/pyensight/core/session.py
CHANGED
|
@@ -172,7 +172,7 @@ class Session:
|
|
|
172
172
|
# are we in a jupyter notebook?
|
|
173
173
|
try:
|
|
174
174
|
_ = get_ipython() # type: ignore
|
|
175
|
-
self._jupyter_notebook = True
|
|
175
|
+
self._jupyter_notebook = True # pragma: no cover
|
|
176
176
|
except NameError:
|
|
177
177
|
self._jupyter_notebook = False
|
|
178
178
|
|
|
@@ -279,7 +279,7 @@ class Session:
|
|
|
279
279
|
If true, actually try to communicate with EnSight. By default false.
|
|
280
280
|
"""
|
|
281
281
|
time_start = time.time()
|
|
282
|
-
while time.time() - time_start < self._timeout:
|
|
282
|
+
while time.time() - time_start < self._timeout: # pragma: no cover
|
|
283
283
|
if self._grpc.is_connected():
|
|
284
284
|
try:
|
|
285
285
|
if validate:
|
|
@@ -287,10 +287,10 @@ class Session:
|
|
|
287
287
|
self._cei_suffix = self.cmd("ensight.version('suffix')")
|
|
288
288
|
self._check_rest_connection()
|
|
289
289
|
return
|
|
290
|
-
except OSError:
|
|
291
|
-
pass
|
|
290
|
+
except OSError: # pragma: no cover
|
|
291
|
+
pass # pragma: no cover
|
|
292
292
|
self._grpc.connect(timeout=self._timeout)
|
|
293
|
-
raise RuntimeError("Unable to establish a gRPC connection to EnSight.")
|
|
293
|
+
raise RuntimeError("Unable to establish a gRPC connection to EnSight.") # pragma: no cover
|
|
294
294
|
|
|
295
295
|
def _check_rest_connection(self) -> None:
|
|
296
296
|
"""Validate the REST API connection works
|
|
@@ -532,7 +532,7 @@ class Session:
|
|
|
532
532
|
|
|
533
533
|
out = []
|
|
534
534
|
dirlen = 0
|
|
535
|
-
if localdir:
|
|
535
|
+
if localdir: # pragma: no cover
|
|
536
536
|
# we use dirlen + 1 here to remove the '/' inserted by os.path.join()
|
|
537
537
|
dirlen = len(localdir) + 1
|
|
538
538
|
for item in filelist:
|
|
@@ -547,7 +547,7 @@ class Session:
|
|
|
547
547
|
out.append((fullname[dirlen:], os.stat(fullname).st_size))
|
|
548
548
|
except Exception:
|
|
549
549
|
pass
|
|
550
|
-
if progress:
|
|
550
|
+
if progress: # pragma: no cover
|
|
551
551
|
try:
|
|
552
552
|
from tqdm.auto import tqdm
|
|
553
553
|
except ImportError:
|
|
@@ -568,7 +568,9 @@ class Session:
|
|
|
568
568
|
data = fp.read(chunk_size)
|
|
569
569
|
if data == b"":
|
|
570
570
|
break
|
|
571
|
-
self.cmd(
|
|
571
|
+
self.cmd(
|
|
572
|
+
f"copy_write_function__(r'{name}', {data!r})", do_eval=False
|
|
573
|
+
) # pragma: no cover
|
|
572
574
|
return out
|
|
573
575
|
|
|
574
576
|
def copy_from_session(
|
|
@@ -713,23 +715,23 @@ class Session:
|
|
|
713
715
|
|
|
714
716
|
"""
|
|
715
717
|
dirname = os.path.dirname(filename)
|
|
716
|
-
if not dirname:
|
|
717
|
-
dirname = "."
|
|
718
|
+
if not dirname: # pragma: no cover
|
|
719
|
+
dirname = "." # pragma: no cover
|
|
718
720
|
if dirname not in sys.path:
|
|
719
721
|
sys.path.append(dirname)
|
|
720
722
|
module_name, _ = os.path.splitext(os.path.basename(filename))
|
|
721
723
|
# get the module reference
|
|
722
724
|
spec = importlib.util.find_spec(module_name)
|
|
723
|
-
if spec:
|
|
725
|
+
if spec: # pragma: no cover
|
|
724
726
|
module = importlib.util.module_from_spec(spec)
|
|
725
727
|
# insert an ensight interface into the module
|
|
726
728
|
if self.ensight:
|
|
727
729
|
module.ensight = self.ensight # type: ignore
|
|
728
730
|
# load (run) the module
|
|
729
|
-
if spec.loader:
|
|
731
|
+
if spec.loader: # pragma: no cover
|
|
730
732
|
spec.loader.exec_module(module)
|
|
731
733
|
return module
|
|
732
|
-
return None
|
|
734
|
+
return None # pragma: no cover
|
|
733
735
|
|
|
734
736
|
def exec(self, function: Callable, *args, remote: bool = False, **kwargs) -> Any:
|
|
735
737
|
"""Run a function containing EnSight API calls locally or in the EnSight interpreter.
|
|
@@ -812,7 +814,9 @@ class Session:
|
|
|
812
814
|
# Create a bound object that allows for direct encoding of the args/kwargs params
|
|
813
815
|
# The new function would be bound_function(ensight) where the args are captured
|
|
814
816
|
# in the lambda.
|
|
815
|
-
bound_function = lambda ens: function(
|
|
817
|
+
bound_function = lambda ens: function( # noqa: E731 # pragma: no cover
|
|
818
|
+
ens, *args, **kwargs
|
|
819
|
+
)
|
|
816
820
|
# Serialize the bound function
|
|
817
821
|
serialized_function = dill.dumps(bound_function, recurse=True)
|
|
818
822
|
self.cmd("import dill", do_eval=False)
|
|
@@ -1022,8 +1026,8 @@ class Session:
|
|
|
1022
1026
|
|
|
1023
1027
|
"""
|
|
1024
1028
|
obj_str = ""
|
|
1025
|
-
if object_id:
|
|
1026
|
-
obj_str = f", id={object_id}"
|
|
1029
|
+
if object_id: # pragma: no cover
|
|
1030
|
+
obj_str = f", id={object_id}" # pragma: no cover
|
|
1027
1031
|
cmd = f"ensight.objs.release_id('{self.name}'{obj_str})"
|
|
1028
1032
|
_ = self.cmd(cmd, do_eval=False)
|
|
1029
1033
|
|
|
@@ -1073,9 +1077,9 @@ class Session:
|
|
|
1073
1077
|
spec = importlib.util.spec_from_file_location(
|
|
1074
1078
|
f"ansys.pyensight.core.utils.{_name}", _filename
|
|
1075
1079
|
)
|
|
1076
|
-
if spec:
|
|
1080
|
+
if spec: # pragma: no cover
|
|
1077
1081
|
_module = importlib.util.module_from_spec(spec)
|
|
1078
|
-
if spec.loader:
|
|
1082
|
+
if spec.loader: # pragma: no cover
|
|
1079
1083
|
spec.loader.exec_module(_module)
|
|
1080
1084
|
# get the class from the module (query.py filename -> Query() object)
|
|
1081
1085
|
_the_class = getattr(_module, _cap_name)
|
|
@@ -1329,8 +1333,8 @@ class Session:
|
|
|
1329
1333
|
|
|
1330
1334
|
"""
|
|
1331
1335
|
base_uri = "https://s3.amazonaws.com/www3.ensight.com/PyEnSight/ExampleData"
|
|
1332
|
-
if root is not None:
|
|
1333
|
-
base_uri = root
|
|
1336
|
+
if root is not None: # pragma: no cover
|
|
1337
|
+
base_uri = root # pragma: no cover
|
|
1334
1338
|
pathname = self.download_pyansys_example(example_name, root=base_uri)
|
|
1335
1339
|
script = f'outpath = r"""{pathname}"""\n'
|
|
1336
1340
|
if uncompress:
|
|
@@ -1600,8 +1604,8 @@ class Session:
|
|
|
1600
1604
|
if tail == -1:
|
|
1601
1605
|
tail_len = 12
|
|
1602
1606
|
tail = s.find(", cached:yes", offset)
|
|
1603
|
-
if tail == -1:
|
|
1604
|
-
break
|
|
1607
|
+
if tail == -1: # pragma: no cover
|
|
1608
|
+
break # pragma: no cover
|
|
1605
1609
|
# just this object substring
|
|
1606
1610
|
tmp = s[start + 7 : tail]
|
|
1607
1611
|
# Subtype (PartType:, AnnotType:, ToolType:)
|
|
@@ -1634,7 +1638,7 @@ class Session:
|
|
|
1634
1638
|
if (classname_lookup is not None) and (subtype in classname_lookup):
|
|
1635
1639
|
classname = classname_lookup[subtype]
|
|
1636
1640
|
subclass_info = f",attr_id={attr_id}, attr_value={subtype}"
|
|
1637
|
-
elif classname_lookup is not None:
|
|
1641
|
+
elif classname_lookup is not None: # pragma: no cover
|
|
1638
1642
|
# if a "subclass" case and no subclass attrid value, ask for it...
|
|
1639
1643
|
remote_name = self.remote_obj(objid)
|
|
1640
1644
|
cmd = f"{remote_name}.getattr({attr_id})"
|
|
@@ -1645,8 +1649,8 @@ class Session:
|
|
|
1645
1649
|
if owned_flag:
|
|
1646
1650
|
subclass_info += ",owned=True"
|
|
1647
1651
|
replace_text = f"session.ensight.objs.{classname}(session, {objid}{subclass_info})"
|
|
1648
|
-
if replace_text is None:
|
|
1649
|
-
break
|
|
1652
|
+
if replace_text is None: # pragma: no cover
|
|
1653
|
+
break # pragma: no cover
|
|
1650
1654
|
offset = start + len(replace_text)
|
|
1651
1655
|
s = prefix + replace_text + suffix
|
|
1652
1656
|
s = s.strip()
|
|
@@ -1752,7 +1756,7 @@ class Session:
|
|
|
1752
1756
|
ens_version = int(self.ensight.version("suffix"))
|
|
1753
1757
|
# handle various input formats
|
|
1754
1758
|
target = version
|
|
1755
|
-
if isinstance(target, str):
|
|
1759
|
+
if isinstance(target, str): # pragma: no cover
|
|
1756
1760
|
# could be 'year RX' or the suffix as a string
|
|
1757
1761
|
if "R" in target:
|
|
1758
1762
|
tmp = [int(x) for x in target.split("R")]
|
|
@@ -1762,14 +1766,14 @@ class Session:
|
|
|
1762
1766
|
# check validity
|
|
1763
1767
|
valid = ens_version == target
|
|
1764
1768
|
at_least = ""
|
|
1765
|
-
if not strict:
|
|
1769
|
+
if not strict: # pragma: no cover
|
|
1766
1770
|
at_least = "at least "
|
|
1767
1771
|
valid = ens_version >= target
|
|
1768
1772
|
if (not valid) and exception:
|
|
1769
1773
|
ens_version = self.ensight.version("version-full")
|
|
1770
1774
|
base_msg = f" ({at_least}'{version}' required, '{ens_version}' current)"
|
|
1771
|
-
if message:
|
|
1772
|
-
message += base_msg
|
|
1775
|
+
if message: # pragma: no cover
|
|
1776
|
+
message += base_msg # pragma: no cover
|
|
1773
1777
|
else:
|
|
1774
1778
|
message = f"A newer version of EnSight is required to use this API:{base_msg}"
|
|
1775
1779
|
raise InvalidEnSightVersion(message)
|
|
@@ -53,10 +53,10 @@ class Export:
|
|
|
53
53
|
return # pragma: no cover
|
|
54
54
|
try:
|
|
55
55
|
_ = self._ensight._session.cmd("dir(ensight.utils.export)")
|
|
56
|
-
except RuntimeError:
|
|
57
|
-
import ansys.pyensight.core
|
|
56
|
+
except RuntimeError: # pragma: no cover
|
|
57
|
+
import ansys.pyensight.core # pragma: no cover
|
|
58
58
|
|
|
59
|
-
raise RuntimeError(
|
|
59
|
+
raise RuntimeError( # pragma: no cover
|
|
60
60
|
f"Remote EnSight session must have PyEnsight version \
|
|
61
61
|
{ansys.pyensight.core.DEFAULT_ANSYS_VERSION} or higher installed to use this API."
|
|
62
62
|
)
|
|
@@ -344,8 +344,8 @@ class Export:
|
|
|
344
344
|
else:
|
|
345
345
|
num_frames = frames
|
|
346
346
|
|
|
347
|
-
if num_frames < 1:
|
|
348
|
-
raise RuntimeError(
|
|
347
|
+
if num_frames < 1: # pragma: no cover
|
|
348
|
+
raise RuntimeError( # pragma: no cover
|
|
349
349
|
"No frames selected. Perhaps a static dataset SOLUTIONTIME request \
|
|
350
350
|
or no FLIPBOOK/KEYFRAME defined."
|
|
351
351
|
)
|
|
@@ -478,7 +478,7 @@ class Export:
|
|
|
478
478
|
GEOM_EXPORT_STL: ".stl",
|
|
479
479
|
}
|
|
480
480
|
|
|
481
|
-
def _geometry_remote(
|
|
481
|
+
def _geometry_remote( # pragma: no cover
|
|
482
482
|
self, format: str, starting_timestep: int, frames: int, delta_timestep: int
|
|
483
483
|
) -> List[bytes]:
|
|
484
484
|
"""EnSight-side implementation.
|
|
@@ -570,7 +570,7 @@ class Export:
|
|
|
570
570
|
self._ensight._session.ensight_version_check("2024 R2")
|
|
571
571
|
cmd = f"ensight.utils.export._geometry_remote('{format}', {starting_timestep}, {frames}, {delta_timestep})"
|
|
572
572
|
raw_data_list = self._ensight._session.cmd(cmd)
|
|
573
|
-
if raw_data_list:
|
|
573
|
+
if raw_data_list: # pragma: no cover
|
|
574
574
|
if len(raw_data_list) == 1:
|
|
575
575
|
with open(filename, "wb") as fp:
|
|
576
576
|
fp.write(raw_data_list[0])
|
|
@@ -580,5 +580,5 @@ class Export:
|
|
|
580
580
|
_filename = f"{filename_base}{str(idx).zfill(3)}{extension}"
|
|
581
581
|
with open(_filename, "wb") as fp:
|
|
582
582
|
fp.write(raw_data)
|
|
583
|
-
else:
|
|
584
|
-
raise IOError("Export was not successful")
|
|
583
|
+
else: # pragma: no cover
|
|
584
|
+
raise IOError("Export was not successful") # pragma: no cover
|
|
@@ -337,6 +337,7 @@ class OmniverseWrapper:
|
|
|
337
337
|
name = name.replace("<", "_").replace(">", "_")
|
|
338
338
|
name = name.replace("/", "_").replace("=", "_")
|
|
339
339
|
name = name.replace(",", "_").replace(" ", "_")
|
|
340
|
+
name = name.replace("\\", "_")
|
|
340
341
|
if id_name is not None:
|
|
341
342
|
name = name + "_" + str(id_name)
|
|
342
343
|
if name in self._cleaned_names.values():
|
|
@@ -52,7 +52,7 @@ def convert_variable(
|
|
|
52
52
|
return var
|
|
53
53
|
elif hasattr(var, "ID"):
|
|
54
54
|
return int(var.ID)
|
|
55
|
-
return None
|
|
55
|
+
return None # pragma: no cover
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
class Parts:
|
|
@@ -214,7 +214,7 @@ class Parts:
|
|
|
214
214
|
found = ensobjlist([p for p, met in metadata.items() if met.get(tag) == value])
|
|
215
215
|
elif value and not tag:
|
|
216
216
|
found = ensobjlist([p for p, met in metadata.items() if value in met.values()])
|
|
217
|
-
elif tag and not value:
|
|
217
|
+
elif tag and not value: # pragma: no cover
|
|
218
218
|
found = ensobjlist([p for p, met in metadata.items() if tag in met.keys()])
|
|
219
219
|
else:
|
|
220
220
|
found = ensobjlist(
|
|
@@ -254,8 +254,10 @@ class Parts:
|
|
|
254
254
|
"""Private routine to create emitter objects"""
|
|
255
255
|
new_emitters: List[Any] = []
|
|
256
256
|
if emitter_type == self._EMIT_POINT:
|
|
257
|
-
if not points:
|
|
258
|
-
raise RuntimeError(
|
|
257
|
+
if not points: # pragma: no cover
|
|
258
|
+
raise RuntimeError(
|
|
259
|
+
"list of points needed if particle trace emitted from points"
|
|
260
|
+
) # pragma: no cover
|
|
259
261
|
for p in points:
|
|
260
262
|
if isinstance(self.ensight, ModuleType): # pragma: no cover
|
|
261
263
|
new_emitters.append(
|
|
@@ -280,7 +282,7 @@ class Parts:
|
|
|
280
282
|
)
|
|
281
283
|
elif emitter_type == self._EMIT_PLANE:
|
|
282
284
|
if not any([point1, point2, point3]):
|
|
283
|
-
raise RuntimeError(
|
|
285
|
+
raise RuntimeError( # pragma: no cover
|
|
284
286
|
"point1, point2 and point3 needed if particle trace emitted from plane"
|
|
285
287
|
)
|
|
286
288
|
if isinstance(self.ensight, ModuleType): # pragma: no cover
|
|
@@ -298,9 +300,11 @@ class Parts:
|
|
|
298
300
|
new_emitters.append(
|
|
299
301
|
f"ensight.utils.parts._EnSEmitterGrid(ensight, point1={point1}, point2={point2}, point3={point3}, num_points_x={num_points_x}, num_points_y={num_points_y})"
|
|
300
302
|
)
|
|
301
|
-
elif emitter_type == self._EMIT_PART:
|
|
302
|
-
if not parts:
|
|
303
|
-
raise RuntimeError(
|
|
303
|
+
elif emitter_type == self._EMIT_PART: # pragma: no cover
|
|
304
|
+
if not parts: # pragma: no cover
|
|
305
|
+
raise RuntimeError(
|
|
306
|
+
"part and num_points needed if particle trace emitted from part"
|
|
307
|
+
) # pragma: no cover
|
|
304
308
|
for p in parts:
|
|
305
309
|
if isinstance(self.ensight, ModuleType): # pragma: no cover
|
|
306
310
|
new_emitters.append( # pragma: no cover
|
|
@@ -316,7 +320,9 @@ class Parts:
|
|
|
316
320
|
f"ensight.utils.parts._EnSEmitterPart(ensight, part={convert_part(self.ensight ,p)}, num_points={num_points}, part_kind={part_distribution_type})"
|
|
317
321
|
)
|
|
318
322
|
else:
|
|
319
|
-
raise RuntimeError(
|
|
323
|
+
raise RuntimeError(
|
|
324
|
+
"No input provided to create the emitters for the particle trace"
|
|
325
|
+
) # pragma: no cover
|
|
320
326
|
return new_emitters
|
|
321
327
|
|
|
322
328
|
def _create_particle_trace_part(
|
|
@@ -349,7 +355,7 @@ class Parts:
|
|
|
349
355
|
def_part.TOTALTIME = total_time
|
|
350
356
|
if delta_time:
|
|
351
357
|
def_part.DELTATIME = delta_time
|
|
352
|
-
if emit_time:
|
|
358
|
+
if emit_time: # pragma: no cover
|
|
353
359
|
def_part.STARTTIME = emit_time
|
|
354
360
|
def_part.DESCRIPTION = name
|
|
355
361
|
def_part.VARIABLE = convert_variable(self.ensight, variable)
|
|
@@ -407,15 +413,17 @@ class Parts:
|
|
|
407
413
|
"""Private utility to cure an input particle trace part and convert it to an ``ENS_PART`"""
|
|
408
414
|
|
|
409
415
|
# the add_emitter* functions were added in 2024 R2
|
|
410
|
-
if not isinstance(self.ensight, ModuleType):
|
|
416
|
+
if not isinstance(self.ensight, ModuleType): # pragma: no cover
|
|
411
417
|
self.ensight._session.ensight_version_check("2024 R2")
|
|
412
418
|
|
|
413
419
|
_particle_trace_part: "ENS_PART_PARTICLE_TRACE"
|
|
414
|
-
if isinstance(particle_trace_part, (str, int)):
|
|
415
|
-
temp = self.ensight.objs.core.PARTS[particle_trace_part]
|
|
416
|
-
if not temp:
|
|
417
|
-
raise RuntimeError(
|
|
418
|
-
|
|
420
|
+
if isinstance(particle_trace_part, (str, int)): # pragma: no cover
|
|
421
|
+
temp = self.ensight.objs.core.PARTS[particle_trace_part] # pragma: no cover
|
|
422
|
+
if not temp: # pragma: no cover
|
|
423
|
+
raise RuntimeError(
|
|
424
|
+
"particle_trace_part input is not a valid part"
|
|
425
|
+
) # pragma: no cover
|
|
426
|
+
_particle_trace_part = temp[0] # pragma: no cover
|
|
419
427
|
else:
|
|
420
428
|
_particle_trace_part = particle_trace_part
|
|
421
429
|
return _particle_trace_part
|
|
@@ -428,29 +436,32 @@ class Parts:
|
|
|
428
436
|
"""Private utility to set the direction if not provided, and to cure the list of source parts."""
|
|
429
437
|
|
|
430
438
|
# the create_particle* functions were added in 2024 R2
|
|
431
|
-
if not isinstance(self.ensight, ModuleType):
|
|
439
|
+
if not isinstance(self.ensight, ModuleType): # pragma: no cover
|
|
432
440
|
self.ensight._session.ensight_version_check("2024 R2")
|
|
433
441
|
|
|
434
442
|
if not direction:
|
|
435
443
|
direction = self.PT_POS_TIME
|
|
436
|
-
if source_parts:
|
|
444
|
+
if source_parts: # pragma: no cover
|
|
437
445
|
converted_source_parts = [convert_part(self.ensight, p) for p in source_parts]
|
|
438
|
-
if not source_parts:
|
|
439
|
-
converted_source_parts = self.ensight.objs.core.selection(
|
|
440
|
-
|
|
441
|
-
|
|
446
|
+
if not source_parts: # pragma: no cover
|
|
447
|
+
converted_source_parts = self.ensight.objs.core.selection( # pragma: no cover
|
|
448
|
+
name="ENS_PART"
|
|
449
|
+
)
|
|
450
|
+
if not converted_source_parts: # pragma: no cover
|
|
451
|
+
raise RuntimeError("No part selected for particle trace generation") # pragma: no cover
|
|
442
452
|
return direction, converted_source_parts
|
|
443
453
|
|
|
444
454
|
def _find_palette(self, color_by: Optional[Union[str, int, "ENS_VAR"]] = None) -> Optional[str]:
|
|
445
455
|
"""Private utility to find the description of the input color_by variable"""
|
|
446
456
|
palette: Optional[str] = None
|
|
447
457
|
if color_by:
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
458
|
+
try:
|
|
459
|
+
_color_by_var: List["ENS_VAR"] = self.ensight.objs.core.VARIABLES.find(
|
|
460
|
+
[convert_variable(self.ensight, color_by)], attr="ID"
|
|
461
|
+
)
|
|
462
|
+
if _color_by_var:
|
|
463
|
+
palette = _color_by_var[0].DESCRIPTION
|
|
464
|
+
except Exception:
|
|
454
465
|
raise RuntimeError(
|
|
455
466
|
"The variable supplied to color the particle trace by does not exist"
|
|
456
467
|
)
|
|
@@ -1141,20 +1152,23 @@ class Parts:
|
|
|
1141
1152
|
p_list = [plist]
|
|
1142
1153
|
elif isinstance(plist, list) or isinstance(plist, ensobjlist):
|
|
1143
1154
|
p_list = [p for p in plist]
|
|
1144
|
-
else:
|
|
1145
|
-
raise RuntimeError(
|
|
1155
|
+
else: # pragma: no cover
|
|
1156
|
+
raise RuntimeError( # pragma: no cover
|
|
1157
|
+
"Unknown type of input var plist {}".format(type(plist))
|
|
1158
|
+
)
|
|
1146
1159
|
#
|
|
1147
1160
|
# p_list must now be a list
|
|
1148
1161
|
#
|
|
1149
1162
|
|
|
1150
1163
|
if not p_list:
|
|
1151
1164
|
return None
|
|
1152
|
-
if not isinstance(p_list[0], (str, int, self.ensight.objs.ENS_PART)):
|
|
1153
|
-
error = "First member is neither ENS_PART, int, nor string"
|
|
1154
|
-
error += f"{p_list[0]} type = {type(p_list[0])}; aborting"
|
|
1155
|
-
raise RuntimeError(error)
|
|
1165
|
+
if not isinstance(p_list[0], (str, int, self.ensight.objs.ENS_PART)): # pragma: no cover
|
|
1166
|
+
error = "First member is neither ENS_PART, int, nor string" # pragma: no cover
|
|
1167
|
+
error += f"{p_list[0]} type = {type(p_list[0])}; aborting" # pragma: no cover
|
|
1168
|
+
raise RuntimeError(error) # pragma: no cover
|
|
1156
1169
|
pobjs: List["ENS_PART"]
|
|
1157
|
-
if isinstance(p_list[0], int):
|
|
1170
|
+
if isinstance(p_list[0], int):
|
|
1171
|
+
# list of ints must be part ids
|
|
1158
1172
|
for pid in p_list:
|
|
1159
1173
|
pobjs = [p for p in self.ensight.objs.core.PARTS if p.PARTNUMBER == pid]
|
|
1160
1174
|
for prt in pobjs:
|
|
@@ -1181,5 +1195,5 @@ class Parts:
|
|
|
1181
1195
|
if ret_flag == "obj":
|
|
1182
1196
|
val_objs = [p for p in pobj_list]
|
|
1183
1197
|
return val_objs
|
|
1184
|
-
val_ints = [int(p.
|
|
1198
|
+
val_ints = [int(p.PARTNUMBER) for p in pobj_list]
|
|
1185
1199
|
return val_ints
|