Skip to content

Commit d955fee

Browse files
Enhance config documentation with examples (#950)
* Update config documentation * Add example for set_config_option call * Update src/ansys/dpf/core/dpf_operator.py Co-authored-by: JennaPaikowsky <[email protected]> * update doc string * Update * up --------- Co-authored-by: JennaPaikowsky <[email protected]>
1 parent b5804b7 commit d955fee

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/ansys/dpf/core/config.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,25 @@ class Config:
3434
Server with the channel connected to the remote or local instance. The default is
3535
``None``, in which case an attempt is made to use the global server.
3636
37+
Examples
38+
--------
39+
Create an operator configuration, instantiate the operator and
40+
run it with the configuration.
41+
42+
>>> from ansys.dpf import core as dpf
43+
>>> config_add = dpf.Config("add")
44+
>>> config_add.set_work_by_index_option(True)
45+
>>> op = dpf.operators.math.add(config=config_add)
46+
47+
Modify the copy of an operator's configuration and set it as current config
48+
of the operator.
49+
50+
>>> from ansys.dpf import core as dpf
51+
>>> op = dpf.operators.math.add()
52+
>>> config_add = op.config
53+
>>> config_add.set_work_by_index_option(True)
54+
>>> op.config = config_add
55+
3756
"""
3857

3958
def __init__(self, operator_name=None, config=None, server=None, spec=None):
@@ -144,6 +163,18 @@ def set_config_option(self, config_name, config_value):
144163
Value to give to a configuration option.
145164
config_name : str
146165
Name of the configuration option.
166+
167+
Examples
168+
--------
169+
Modify the copy of an operator's configuration and set it as current config
170+
of the operator.
171+
172+
>>> from ansys.dpf import core as dpf
173+
>>> op = dpf.operators.math.add()
174+
>>> config_add = op.config
175+
>>> config_add.set_config_option(config_name="work_by_index", config_value=True)
176+
>>> op.config = config_add
177+
147178
"""
148179
return self.__set_config_option__(config_value, config_name)
149180

src/ansys/dpf/core/dpf_operator.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,12 +474,26 @@ def config(self):
474474
"""Copy of the operator's current configuration.
475475
476476
You can modify the copy of the configuration and then use ``operator.config = new_config``
477-
or create an operator with the new configuration as a parameter.
477+
or instantiate an operator with the new configuration as a parameter.
478+
479+
For information on an operator's options, see the documentation for that operator.
478480
479481
Returns
480482
----------
481483
:class:`ansys.dpf.core.config.Config`
482484
Copy of the operator's current configuration.
485+
486+
Examples
487+
--------
488+
Modify the copy of an operator's configuration and set it as current config
489+
of the operator.
490+
491+
>>> from ansys.dpf import core as dpf
492+
>>> op = dpf.operators.math.add()
493+
>>> config_add = op.config
494+
>>> config_add.set_work_by_index_option(True)
495+
>>> op.config = config_add
496+
483497
"""
484498
config = self._api.operator_get_config(self)
485499
return Config(config=config, server=self._server, spec=self._spec)

0 commit comments

Comments
 (0)