Skip to content

Commit 86a359f

Browse files
Update generated code for DPF 261_daily on main (#2538)
Co-authored-by: PProfizi <[email protected]>
1 parent 63f12cb commit 86a359f

24 files changed

+6768
-165
lines changed

doc/source/_static/dpf_operators.html

Lines changed: 280 additions & 164 deletions
Large diffs are not rendered by default.
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)