Skip to content

Commit 1ac82c4

Browse files
authored
Merge branch 'main' into chore/try_excepts_pass
2 parents 489b52e + aff43d9 commit 1ac82c4

28 files changed

+6814
-183
lines changed

SECURITY.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Reporting a vulnerability
2+
3+
> [!CAUTION]
4+
> Do not use GitHub issues to report any security vulnerabilities.
5+
6+
If you detect a vulnerability, contact the [PyAnsys Core team](mailto:[email protected]),
7+
mentioning the repository and the details of your finding. The team will address it as soon as possible.
8+
9+
Provide the PyAnsys Core team with this information:
10+
11+
- Any specific configuration settings needed to reproduce the problem
12+
- Step-by-step guidance to reproduce the problem
13+
- The exact location of the problematic source code, including tag, branch, commit, or a direct URL
14+
- The potential consequences of the vulnerability, along with a description of how an attacker could take advantage of the issue

doc/source/_static/dpf_operators.html

Lines changed: 280 additions & 164 deletions
Large diffs are not rendered by default.

pytest.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[pytest]
22
filterwarnings =
3-
ignore::FutureWarning
4-
ignore::PendingDeprecationWarning
5-
ignore::DeprecationWarning
3+
; ignore:Use explicit output-to-input connections:DeprecationWarning
64
norecursedirs = *
7-
doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS
5+
doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS
6+
markers =
7+
slow: mark a test as slow.

src/ansys/dpf/core/examples/downloads.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def delete_downloads(verbose=True):
5858
Path(examples.__file__).parent / "__init__.py",
5959
Path(examples.__file__).parent / "downloads.py",
6060
Path(examples.__file__).parent / "examples.py",
61+
Path(examples.__file__).parent / "python_plugins" / "custom_operator_example.py",
6162
]
6263
)
6364
for root, dirs, files in os.walk(LOCAL_DOWNLOADED_EXAMPLES_PATH, topdown=False):

src/ansys/dpf/core/model.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from typing import TYPE_CHECKING
3232

3333
if TYPE_CHECKING: # pragma: nocover
34+
from ansys.dpf.core.operators.mesh.mesh_provider import mesh_provider as mesh_provider_op
3435
from ansys.dpf.core.scoping import Scoping
3536
from ansys.dpf.core.server_types import AnyServerType
3637

@@ -321,7 +322,7 @@ def _cache_streams_provider(self):
321322
)
322323
else:
323324
self._stream_provider = Operator("stream_provider", server=self._server)
324-
self._stream_provider.inputs.connect(self._data_sources)
325+
self._stream_provider.inputs.data_sources.connect(self._data_sources)
325326
try:
326327
self._stream_provider.run()
327328
except:
@@ -369,12 +370,16 @@ def time_freq_support(self):
369370
370371
"""
371372
if self._time_freq_support is None:
372-
timeProvider = Operator("TimeFreqSupportProvider", server=self._server)
373+
time_provider: dpf.core.operators.metadata.time_freq_provider = Operator(
374+
name="TimeFreqSupportProvider", server=self._server
375+
)
373376
if self._stream_provider:
374-
timeProvider.inputs.connect(self._stream_provider.outputs)
377+
time_provider.inputs.streams_container.connect(
378+
self._stream_provider.outputs.streams_container
379+
)
375380
else:
376-
timeProvider.inputs.connect(self.data_sources)
377-
self._time_freq_support = timeProvider.get_output(0, types.time_freq_support)
381+
time_provider.inputs.data_sources.connect(self.data_sources)
382+
self._time_freq_support = time_provider.get_output(0, types.time_freq_support)
378383
return self._time_freq_support
379384

380385
@property
@@ -443,7 +448,7 @@ def _set_data_sources(self, var_inp):
443448
def _load_result_info(self):
444449
"""Return a result info object."""
445450
op = Operator("ResultInfoProvider", server=self._server)
446-
op.inputs.connect(self._stream_provider.outputs)
451+
op.inputs.streams_container.connect(self._stream_provider.outputs.streams_container)
447452
try:
448453
result_info = op.get_output(0, types.result_info)
449454
except Exception as e:
@@ -491,7 +496,7 @@ def meshed_region(self):
491496
return self._meshed_region
492497

493498
@property
494-
def mesh_provider(self):
499+
def mesh_provider(self) -> mesh_provider_op:
495500
"""Mesh provider operator.
496501
497502
This operator reads a mesh from the result file. The underlying
@@ -500,15 +505,19 @@ def mesh_provider(self):
500505
501506
Returns
502507
-------
503-
mesh_provider : :class:`ansys.dpf.core.operators.mesh.mesh_provider`
508+
mesh_provider:
504509
Mesh provider operator.
505510
506511
"""
507-
mesh_provider = Operator("MeshProvider", server=self._server)
512+
mesh_provider: dpf.core.operators.mesh.mesh_provider = Operator(
513+
name="MeshProvider", server=self._server
514+
)
508515
if self._stream_provider:
509-
mesh_provider.inputs.connect(self._stream_provider.outputs)
516+
mesh_provider.inputs.streams_container.connect(
517+
self._stream_provider.outputs.streams_container
518+
)
510519
else:
511-
mesh_provider.inputs.connect(self.data_sources)
520+
mesh_provider.inputs.data_sources.connect(self.data_sources)
512521
return mesh_provider
513522

514523
@property
@@ -577,11 +586,15 @@ def meshes_provider(self):
577586
Underlying operator symbol is
578587
"meshes_provider" operator
579588
"""
580-
meshes_provider = Operator("meshes_provider", server=self._server)
589+
meshes_provider: dpf.core.operators.mesh.meshes_provider = Operator(
590+
name="meshes_provider", server=self._server
591+
)
581592
if self._stream_provider:
582-
meshes_provider.inputs.connect(self._stream_provider.outputs)
593+
meshes_provider.inputs.streams_container.connect(
594+
self._stream_provider.outputs.streams_container
595+
)
583596
else:
584-
meshes_provider.inputs.connect(self.data_sources)
597+
meshes_provider.inputs.data_sources.connect(self.data_sources)
585598
return meshes_provider
586599

587600
@property
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from .apply_svd import apply_svd
22
from .apply_zfp import apply_zfp
33
from .kmeans_clustering import kmeans_clustering
4+
from .quantization import quantization
5+
from .quantization_fc import quantization_fc
46
from .zfp_decompress import zfp_decompress
Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
"""
2+
quantization
3+
4+
Autogenerated DPF operator classes.
5+
"""
6+
7+
from __future__ import annotations
8+
9+
from warnings import warn
10+
from ansys.dpf.core.dpf_operator import Operator
11+
from ansys.dpf.core.inputs import Input, _Inputs
12+
from ansys.dpf.core.outputs import Output, _Outputs
13+
from ansys.dpf.core.operators.specification import PinSpecification, Specification
14+
from ansys.dpf.core.config import Config
15+
from ansys.dpf.core.server_types import AnyServerType
16+
17+
18+
class quantization(Operator):
19+
r"""Applies scaling to precision to all the values from field input, then
20+
rounding to the unit.
21+
22+
23+
Parameters
24+
----------
25+
input_field: Field
26+
Input field
27+
threshold: float
28+
Threshold (precision) desired.
29+
30+
Returns
31+
-------
32+
output_field: Field
33+
Scaled and rounded field
34+
35+
Examples
36+
--------
37+
>>> from ansys.dpf import core as dpf
38+
39+
>>> # Instantiate operator
40+
>>> op = dpf.operators.compression.quantization()
41+
42+
>>> # Make input connections
43+
>>> my_input_field = dpf.Field()
44+
>>> op.inputs.input_field.connect(my_input_field)
45+
>>> my_threshold = float()
46+
>>> op.inputs.threshold.connect(my_threshold)
47+
48+
>>> # Instantiate operator and connect inputs in one line
49+
>>> op = dpf.operators.compression.quantization(
50+
... input_field=my_input_field,
51+
... threshold=my_threshold,
52+
... )
53+
54+
>>> # Get output data
55+
>>> result_output_field = op.outputs.output_field()
56+
"""
57+
58+
def __init__(self, input_field=None, threshold=None, config=None, server=None):
59+
super().__init__(name="quantization", config=config, server=server)
60+
self._inputs = InputsQuantization(self)
61+
self._outputs = OutputsQuantization(self)
62+
if input_field is not None:
63+
self.inputs.input_field.connect(input_field)
64+
if threshold is not None:
65+
self.inputs.threshold.connect(threshold)
66+
67+
@staticmethod
68+
def _spec() -> Specification:
69+
description = r"""Applies scaling to precision to all the values from field input, then
70+
rounding to the unit.
71+
"""
72+
spec = Specification(
73+
description=description,
74+
map_input_pin_spec={
75+
0: PinSpecification(
76+
name="input_field",
77+
type_names=["field"],
78+
optional=False,
79+
document=r"""Input field""",
80+
),
81+
1: PinSpecification(
82+
name="threshold",
83+
type_names=["double"],
84+
optional=False,
85+
document=r"""Threshold (precision) desired.""",
86+
),
87+
},
88+
map_output_pin_spec={
89+
0: PinSpecification(
90+
name="output_field",
91+
type_names=["field"],
92+
optional=False,
93+
document=r"""Scaled and rounded field""",
94+
),
95+
},
96+
)
97+
return spec
98+
99+
@staticmethod
100+
def default_config(server: AnyServerType = None) -> Config:
101+
"""Returns the default config of the operator.
102+
103+
This config can then be changed to the user needs and be used to
104+
instantiate the operator. The Configuration allows to customize
105+
how the operation will be processed by the operator.
106+
107+
Parameters
108+
----------
109+
server:
110+
Server with channel connected to the remote or local instance. When
111+
``None``, attempts to use the global server.
112+
113+
Returns
114+
-------
115+
config:
116+
A new Config instance equivalent to the default config for this operator.
117+
"""
118+
return Operator.default_config(name="quantization", server=server)
119+
120+
@property
121+
def inputs(self) -> InputsQuantization:
122+
"""Enables to connect inputs to the operator
123+
124+
Returns
125+
--------
126+
inputs:
127+
An instance of InputsQuantization.
128+
"""
129+
return super().inputs
130+
131+
@property
132+
def outputs(self) -> OutputsQuantization:
133+
"""Enables to get outputs of the operator by evaluating it
134+
135+
Returns
136+
--------
137+
outputs:
138+
An instance of OutputsQuantization.
139+
"""
140+
return super().outputs
141+
142+
143+
class InputsQuantization(_Inputs):
144+
"""Intermediate class used to connect user inputs to
145+
quantization operator.
146+
147+
Examples
148+
--------
149+
>>> from ansys.dpf import core as dpf
150+
>>> op = dpf.operators.compression.quantization()
151+
>>> my_input_field = dpf.Field()
152+
>>> op.inputs.input_field.connect(my_input_field)
153+
>>> my_threshold = float()
154+
>>> op.inputs.threshold.connect(my_threshold)
155+
"""
156+
157+
def __init__(self, op: Operator):
158+
super().__init__(quantization._spec().inputs, op)
159+
self._input_field = Input(quantization._spec().input_pin(0), 0, op, -1)
160+
self._inputs.append(self._input_field)
161+
self._threshold = Input(quantization._spec().input_pin(1), 1, op, -1)
162+
self._inputs.append(self._threshold)
163+
164+
@property
165+
def input_field(self) -> Input:
166+
r"""Allows to connect input_field input to the operator.
167+
168+
Input field
169+
170+
Returns
171+
-------
172+
input:
173+
An Input instance for this pin.
174+
175+
Examples
176+
--------
177+
>>> from ansys.dpf import core as dpf
178+
>>> op = dpf.operators.compression.quantization()
179+
>>> op.inputs.input_field.connect(my_input_field)
180+
>>> # or
181+
>>> op.inputs.input_field(my_input_field)
182+
"""
183+
return self._input_field
184+
185+
@property
186+
def threshold(self) -> Input:
187+
r"""Allows to connect threshold input to the operator.
188+
189+
Threshold (precision) desired.
190+
191+
Returns
192+
-------
193+
input:
194+
An Input instance for this pin.
195+
196+
Examples
197+
--------
198+
>>> from ansys.dpf import core as dpf
199+
>>> op = dpf.operators.compression.quantization()
200+
>>> op.inputs.threshold.connect(my_threshold)
201+
>>> # or
202+
>>> op.inputs.threshold(my_threshold)
203+
"""
204+
return self._threshold
205+
206+
207+
class OutputsQuantization(_Outputs):
208+
"""Intermediate class used to get outputs from
209+
quantization operator.
210+
211+
Examples
212+
--------
213+
>>> from ansys.dpf import core as dpf
214+
>>> op = dpf.operators.compression.quantization()
215+
>>> # Connect inputs : op.inputs. ...
216+
>>> result_output_field = op.outputs.output_field()
217+
"""
218+
219+
def __init__(self, op: Operator):
220+
super().__init__(quantization._spec().outputs, op)
221+
self._output_field = Output(quantization._spec().output_pin(0), 0, op)
222+
self._outputs.append(self._output_field)
223+
224+
@property
225+
def output_field(self) -> Output:
226+
r"""Allows to get output_field output of the operator
227+
228+
Scaled and rounded field
229+
230+
Returns
231+
-------
232+
output:
233+
An Output instance for this pin.
234+
235+
Examples
236+
--------
237+
>>> from ansys.dpf import core as dpf
238+
>>> op = dpf.operators.compression.quantization()
239+
>>> # Get the output from op.outputs. ...
240+
>>> result_output_field = op.outputs.output_field()
241+
"""
242+
return self._output_field

0 commit comments

Comments
 (0)