ansys-pyensight-core 0.7.8__py3-none-any.whl → 0.7.10__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/__init__.py +1 -1
- 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 +803 -798
- 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.10.dist-info}/METADATA +2 -2
- ansys_pyensight_core-0.7.10.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.10.dist-info}/LICENSE +0 -0
- {ansys_pyensight_core-0.7.8.dist-info → ansys_pyensight_core-0.7.10.dist-info}/WHEEL +0 -0
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
|
|
@@ -160,27 +160,31 @@ class Query:
|
|
|
160
160
|
>>> point1=pnt1, point2=pnt2, new_plotter=True)
|
|
161
161
|
|
|
162
162
|
"""
|
|
163
|
-
if query_type not in [
|
|
164
|
-
|
|
163
|
+
if query_type not in [
|
|
164
|
+
self.DISTANCE_PART1D,
|
|
165
|
+
self.DISTANCE_LINE,
|
|
166
|
+
self.DISTANCE_SPLINE,
|
|
167
|
+
]: # pragma: no cover
|
|
168
|
+
raise RuntimeError(f"Invalid query type: {query_type} specified.") # pragma: no cover
|
|
165
169
|
|
|
166
170
|
var1 = self._get_variable(variable1)
|
|
167
171
|
var2 = self._get_variable(variable2, "DISTANCE")
|
|
168
172
|
|
|
169
173
|
if query_type == self.DISTANCE_LINE:
|
|
170
|
-
if (point1 is None) or (point2 is None):
|
|
171
|
-
raise RuntimeError("Both point1 and point2 must be specified.")
|
|
174
|
+
if (point1 is None) or (point2 is None): # pragma: no cover
|
|
175
|
+
raise RuntimeError("Both point1 and point2 must be specified.") # pragma: no cover
|
|
172
176
|
self._create_query_core_begin(name, part_list)
|
|
173
177
|
self._ensight.query_ent_var.number_of_sample_pts(num_samples)
|
|
174
178
|
self._ensight.query_ent_var.constrain("line_tool")
|
|
175
179
|
self._ensight.query_ent_var.line_loc(1, *point1)
|
|
176
180
|
self._ensight.query_ent_var.line_loc(2, *point2)
|
|
177
181
|
|
|
178
|
-
elif query_type == self.DISTANCE_PART1D:
|
|
182
|
+
elif query_type == self.DISTANCE_PART1D: # pragma: no cover
|
|
179
183
|
self._create_query_core_begin(name, part_list, single=True)
|
|
180
184
|
self._ensight.query_ent_var.constrain("1d_part")
|
|
181
185
|
self._ensight.query_ent_var.multiple_segments_by(segments_by)
|
|
182
186
|
|
|
183
|
-
elif query_type == self.DISTANCE_SPLINE:
|
|
187
|
+
elif query_type == self.DISTANCE_SPLINE: # pragma: no cover
|
|
184
188
|
if spline_name is None:
|
|
185
189
|
raise RuntimeError("A spline_name must be specified.")
|
|
186
190
|
self._create_query_core_begin(name, part_list)
|
|
@@ -291,7 +295,7 @@ class Query:
|
|
|
291
295
|
>>> s.ensight.utils.query.TEMPORAL_MAXIMUM, parts, "plastic", new_plotter=True)
|
|
292
296
|
|
|
293
297
|
"""
|
|
294
|
-
if query_type not in [
|
|
298
|
+
if query_type not in [ # pragma: no cover
|
|
295
299
|
self.TEMPORAL_NODE,
|
|
296
300
|
self.TEMPORAL_ELEMENT,
|
|
297
301
|
self.TEMPORAL_IJK,
|
|
@@ -299,19 +303,19 @@ class Query:
|
|
|
299
303
|
self.TEMPORAL_MINIMUM,
|
|
300
304
|
self.TEMPORAL_MAXIMUM,
|
|
301
305
|
]:
|
|
302
|
-
raise RuntimeError(f"Invalid query type: {query_type} specified.")
|
|
306
|
+
raise RuntimeError(f"Invalid query type: {query_type} specified.") # pragma: no cover
|
|
303
307
|
|
|
304
308
|
var1 = self._get_variable(variable1)
|
|
305
309
|
var2 = self._get_variable(variable2, "TIME")
|
|
306
310
|
|
|
307
311
|
# default the time range
|
|
308
|
-
if start_time is None:
|
|
312
|
+
if start_time is None: # pragma: no cover
|
|
309
313
|
start_time = self._ensight.objs.core.SOLUTIONTIME_LIMITS[0]
|
|
310
|
-
if end_time is None:
|
|
314
|
+
if end_time is None: # pragma: no cover
|
|
311
315
|
end_time = self._ensight.objs.core.SOLUTIONTIME_LIMITS[1]
|
|
312
316
|
|
|
313
317
|
# default the number of timesteps
|
|
314
|
-
if num_samples is None:
|
|
318
|
+
if num_samples is None: # pragma: no cover
|
|
315
319
|
num_samples = (
|
|
316
320
|
self._ensight.objs.core.TIMESTEP_LIMITS[1]
|
|
317
321
|
- self._ensight.objs.core.TIMESTEP_LIMITS[0]
|
|
@@ -319,38 +323,38 @@ class Query:
|
|
|
319
323
|
)
|
|
320
324
|
|
|
321
325
|
if query_type == self.TEMPORAL_NODE:
|
|
322
|
-
if node_id is None:
|
|
323
|
-
raise RuntimeError("node_id must be specified.")
|
|
326
|
+
if node_id is None: # pragma: no cover
|
|
327
|
+
raise RuntimeError("node_id must be specified.") # pragma: no cover
|
|
324
328
|
self._create_query_core_begin(name, part_list)
|
|
325
329
|
self._ensight.query_ent_var.constrain("node")
|
|
326
330
|
self._ensight.query_ent_var.node_id(node_id)
|
|
327
331
|
|
|
328
332
|
elif query_type == self.TEMPORAL_ELEMENT:
|
|
329
|
-
if element_id is None:
|
|
330
|
-
raise RuntimeError("element_id must be specified.")
|
|
333
|
+
if element_id is None: # pragma: no cover
|
|
334
|
+
raise RuntimeError("element_id must be specified.") # pragma: no cover
|
|
331
335
|
self._create_query_core_begin(name, part_list)
|
|
332
336
|
self._ensight.query_ent_var.constrain("element")
|
|
333
337
|
self._ensight.query_ent_var.elem_id(element_id)
|
|
334
338
|
|
|
335
339
|
elif query_type == self.TEMPORAL_XYZ:
|
|
336
|
-
if xyz is None:
|
|
337
|
-
raise RuntimeError("xyz must be specified.")
|
|
340
|
+
if xyz is None: # pragma: no cover
|
|
341
|
+
raise RuntimeError("xyz must be specified.") # pragma: no cover
|
|
338
342
|
self._create_query_core_begin(name, part_list)
|
|
339
343
|
self._ensight.query_ent_var.constrain("cursor")
|
|
340
344
|
self._ensight.query_ent_var.cursor_loc(*xyz)
|
|
341
345
|
|
|
342
346
|
elif query_type == self.TEMPORAL_IJK:
|
|
343
|
-
if ijk is None:
|
|
344
|
-
raise RuntimeError("ijk must be specified.")
|
|
345
|
-
self._create_query_core_begin(name, part_list)
|
|
346
|
-
self._ensight.query_ent_var.constrain("ijk")
|
|
347
|
-
self._ensight.query_ent_var.ijk(*ijk)
|
|
347
|
+
if ijk is None: # pragma: no cover
|
|
348
|
+
raise RuntimeError("ijk must be specified.") # pragma: no cover
|
|
349
|
+
self._create_query_core_begin(name, part_list) # pragma: no cover
|
|
350
|
+
self._ensight.query_ent_var.constrain("ijk") # pragma: no cover
|
|
351
|
+
self._ensight.query_ent_var.ijk(*ijk) # pragma: no cover
|
|
348
352
|
|
|
349
353
|
elif query_type == self.TEMPORAL_MINIMUM:
|
|
350
354
|
self._create_query_core_begin(name, part_list)
|
|
351
355
|
self._ensight.query_ent_var.constrain("min")
|
|
352
356
|
|
|
353
|
-
elif query_type == self.TEMPORAL_MAXIMUM:
|
|
357
|
+
elif query_type == self.TEMPORAL_MAXIMUM: # pragma: no cover
|
|
354
358
|
self._create_query_core_begin(name, part_list)
|
|
355
359
|
self._ensight.query_ent_var.constrain("max")
|
|
356
360
|
|
|
@@ -388,12 +392,12 @@ class Query:
|
|
|
388
392
|
try:
|
|
389
393
|
query = max(self._ensight.objs.core.QUERIES)
|
|
390
394
|
# no new id allocated
|
|
391
|
-
if query.__OBJID__ < nextid:
|
|
392
|
-
error_msg = "Unable to create the specified query."
|
|
393
|
-
except ValueError:
|
|
394
|
-
error_msg = "Unable to create the specified query."
|
|
395
|
-
if error_msg:
|
|
396
|
-
raise RuntimeError(error_msg)
|
|
395
|
+
if query.__OBJID__ < nextid: # pragma: no cover
|
|
396
|
+
error_msg = "Unable to create the specified query." # pragma: no cover
|
|
397
|
+
except ValueError: # pragma: no cover
|
|
398
|
+
error_msg = "Unable to create the specified query." # pragma: no cover
|
|
399
|
+
if error_msg: # pragma: no cover
|
|
400
|
+
raise RuntimeError(error_msg) # pragma: no cover
|
|
397
401
|
return query
|
|
398
402
|
|
|
399
403
|
def _create_query_core_begin(self, name: str, parts: Optional[List[int]], single=False) -> None:
|
|
@@ -414,14 +418,16 @@ class Query:
|
|
|
414
418
|
|
|
415
419
|
"""
|
|
416
420
|
part_list = []
|
|
417
|
-
if parts:
|
|
421
|
+
if parts: # pragma: no cover
|
|
418
422
|
for p in parts:
|
|
419
|
-
if type(p) == str:
|
|
420
|
-
part_list.append(
|
|
421
|
-
|
|
422
|
-
|
|
423
|
+
if type(p) == str: # pragma: no cover
|
|
424
|
+
part_list.append(
|
|
425
|
+
self._ensight.objs.core.PARTS[p][0].PARTNUMBER
|
|
426
|
+
) # pragma: no cover
|
|
427
|
+
elif type(p) == int: # pragma: no cover
|
|
428
|
+
part_list.append(p) # pragma: no cover
|
|
423
429
|
else:
|
|
424
|
-
if hasattr(p, "PARTNUMBER"):
|
|
430
|
+
if hasattr(p, "PARTNUMBER"): # pragma: no cover
|
|
425
431
|
part_list.append(p.PARTNUMBER)
|
|
426
432
|
if not single:
|
|
427
433
|
self._ensight.part.select_begin(part_list)
|