Skip to content

Commit 0d7bba7

Browse files
committed
doc: modified final set of files.
1 parent 2717fd5 commit 0d7bba7

24 files changed

+587
-152
lines changed

src/ansys/dpf/core/operator_specification.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def __str__(self):
320320
@property
321321
def properties(self) -> dict:
322322
"""Additional properties of the Operator.
323-
323+
324324
Some additional properties of the Operator, like the category, the exposure,
325325
the scripting and user names, and the plugin
326326
@@ -592,7 +592,7 @@ def __setitem__(self, key, value):
592592
"""
593593
Set the value of a specified attribute.
594594
595-
If a specification is defined, the value is also updated in the
595+
If a specification is defined, the value is also updated in the
596596
operator specification.
597597
598598
Parameters
@@ -621,7 +621,7 @@ def __getitem__(self, item: str):
621621
-------
622622
any
623623
The value of the specified attribute.
624-
"""
624+
"""
625625
return getattr(self, item)
626626

627627
def __eq__(self, other):
@@ -836,7 +836,7 @@ def config_specification(self, val: list):
836836
@version_requires("4.0")
837837
def properties(self) -> SpecificationProperties:
838838
"""Return additional properties of the Operator.
839-
839+
840840
Returns some additional properties of the Operator, like the category, the exposure,
841841
the scripting and user names and the plugin
842842
"""

src/ansys/dpf/core/result_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ def __len__(self):
589589
"""
590590
Return the number of results available.
591591
592-
If an exception occurs while attempting to retrieve the number of results,
592+
If an exception occurs while attempting to retrieve the number of results,
593593
the method returns 0.
594594
595595
Returns
@@ -633,7 +633,7 @@ def __del__(self):
633633
"""
634634
Clean up resources associated with the instance.
635635
636-
This method calls the deleter function to release resources. If an exception
636+
This method calls the deleter function to release resources. If an exception
637637
occurs during deletion, a warning is issued.
638638
639639
Raises

src/ansys/dpf/core/results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def __result__(self, result_type, *args):
137137
-------
138138
Result
139139
An instance of the `Result` class, providing access to the specified result.
140-
"""
140+
"""
141141
return Result(self._connector, self._mesh_by_default, result_type, self._server)
142142

143143
def _connect_operators(self, result_info):

src/ansys/dpf/core/runtime_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, data_tree, server=None):
3939

4040
class RuntimeClientConfig(_RuntimeConfig):
4141
"""Enable accessing and setting runtime configuration options to gRPC client.
42-
42+
4343
Mostly used to configure gRPC streaming and calls options.
4444
4545
Parameters
@@ -123,7 +123,7 @@ def stream_floats_instead_of_doubles(self, value):
123123
@property
124124
def return_arrays(self):
125125
"""All methods will return :class:`ansys.dpf.core.DPFArray` (instead of lists) when possible.
126-
126+
127127
Default is ``True``.
128128
See for example, :func:`ansys.dpf.core.Scoping.ids`.
129129

src/ansys/dpf/core/scoping.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,22 +335,22 @@ def __del__(self):
335335
"""
336336
Clean up resources associated with the instance.
337337
338-
This method calls the deleter function to release resources. If an exception
338+
This method calls the deleter function to release resources. If an exception
339339
occurs during deletion, a warning is issued.
340340
341341
Raises
342342
------
343343
Warning
344344
If an exception occurs while attempting to delete resources.
345-
"""
345+
"""
346346
try:
347347
self._deleter_func[0](self._deleter_func[1](self))
348348
except Exception as e:
349349
print(str(e.args), str(self._deleter_func[0]))
350350
warnings.warn(traceback.format_exc())
351351

352352
def __iter__(self):
353-
"""Return an iterator over the scoping ids."""
353+
"""Return an iterator over the scoping ids."""
354354
return self.ids.__iter__()
355355

356356
def __getitem__(self, key):

src/ansys/dpf/core/server.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# SOFTWARE.
2222

2323
"""
24-
Server
24+
Server.
2525
2626
Contains the directives necessary to start the DPF server.
2727
"""
@@ -53,6 +53,7 @@
5353

5454

5555
def shutdown_global_server():
56+
"""Shut down the global DPF server."""
5657
try:
5758
if dpf.core.SERVER is not None:
5859
dpf.core.SERVER = None
@@ -103,7 +104,7 @@ def _global_server() -> BaseServer:
103104

104105

105106
def set_server_configuration(server_config: ServerConfig) -> None:
106-
"""Sets, for the current python session, the default type of DPF server to use.
107+
"""Set the default type of DPF server to use for the current python session, .
107108
108109
Parameters
109110
----------
@@ -399,7 +400,7 @@ def connect():
399400

400401

401402
def get_or_create_server(server: BaseServer) -> Union[BaseServer, None]:
402-
"""Returns the given server or if None, creates a new one.
403+
"""Return the given server or if None, creates a new one.
403404
404405
Parameters
405406
----------
@@ -415,7 +416,7 @@ def get_or_create_server(server: BaseServer) -> Union[BaseServer, None]:
415416

416417

417418
def available_servers():
418-
"""Searches all available installed DPF servers on the current machine.
419+
"""Search all available installed DPF servers on the current machine.
419420
420421
This method binds new functions to the server module, which helps to choose the appropriate version.
421422

src/ansys/dpf/core/server_context.py

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# SOFTWARE.
2222

2323
"""
24-
ServerContext
24+
ServerContext.
2525
2626
Gives the ability to choose the context with which the server should be started.
2727
The context allows you to choose the licensing logic for operators.
@@ -43,6 +43,8 @@
4343

4444

4545
class LicensingContextType(Enum):
46+
"""Enum representing different types of licensing contexts."""
47+
4648
none = 5
4749
premium = 1
4850
"""Checks if at least one license increment exists
@@ -52,10 +54,33 @@ class LicensingContextType(Enum):
5254
and does not allow operators to block an increment."""
5355

5456
def __int__(self):
57+
"""
58+
Return the integer values of the licensing context.
59+
60+
Returns
61+
-------
62+
int
63+
Integer values corresponding to the licensing context.
64+
"""
5565
return self.value
5666

5767
@staticmethod
5868
def same_licensing_context(first, second):
69+
"""
70+
Determine if two licensing contexts are compatible.
71+
72+
Parameters
73+
----------
74+
first : LicensingContextType
75+
The first licensing context to compare.
76+
second : LicensingContextType
77+
The second licensing context to compare.
78+
79+
Returns
80+
-------
81+
bool
82+
True if the licensing contexts are compatible, False otherwise.
83+
"""
5984
if (first == LicensingContextType.none and second != LicensingContextType.none) or (
6085
first != LicensingContextType.none and second == LicensingContextType.none
6186
):
@@ -73,6 +98,7 @@ def same_licensing_context(first, second):
7398

7499
class LicenseContextManager:
75100
"""Can optionally be used to check out a license before using licensed DPF Operators.
101+
76102
Improves performance if you are using multiple Operators that require licensing.
77103
It can also be used to force checkout before running a script when few
78104
Ansys license increments are available.
@@ -152,13 +178,45 @@ def release_data(self):
152178
self._license_checkout_operator = None
153179

154180
def __enter__(self):
181+
"""
182+
Enter the runtime context for the license context manager.
183+
184+
This method is called when the object is used within a `with` statement.
185+
It ensures that the license is checked out before the operations within the context block are executed.
186+
187+
Returns
188+
-------
189+
LicenseContextManager
190+
The current instance of the license context manager.
191+
"""
155192
return self
156193

157194
def __exit__(self, type, value, tb):
195+
"""
196+
Exit the runtime context for the license context manager.
197+
198+
This method is called at the end of a `with` statement. It ensures
199+
that the license is checked in and any resources allocated are released.
200+
201+
Parameters
202+
----------
203+
type : type or None
204+
The exception type, if an exception occurred within the context block, or None otherwise.
205+
value : Exception or None
206+
The exception instance, if an exception occurred within the context block, or None otherwise.
207+
tb : traceback or None
208+
The traceback object, if an exception occurred within the context block, or None otherwise.
209+
210+
Returns
211+
-------
212+
bool
213+
If True, suppresses the exception. Otherwise, the exception is propagated.
214+
"""
158215
if tb is None:
159216
self.release_data()
160217

161218
def __del__(self):
219+
"""Release the license when the instance is deleted."""
162220
self.release_data()
163221
pass
164222

@@ -176,6 +234,7 @@ def status(self):
176234

177235
class ServerContext:
178236
"""The context defines whether DPF capabilities requiring a license checkout are allowed.
237+
179238
xml_path argument won't be taken into account if using LicensingContextType.entry.
180239
181240
Parameters
@@ -211,13 +270,15 @@ def xml_path(self):
211270
return self._xml_path
212271

213272
def __str__(self):
273+
"""Return string representation of the ServerContext instance."""
214274
return (
215275
f"Server Context of type {self.licensing_context_type}"
216276
f" with {'no' if len(self.xml_path) == 0 else ''} xml path"
217277
f"{'' if len(self.xml_path) == 0 else ': ' + self.xml_path}"
218278
)
219279

220280
def __eq__(self, other):
281+
"""Compare two ServerContext instances for equality."""
221282
if not isinstance(other, ServerContext):
222283
return False
223284
return os.path.normpath(self.xml_path) == os.path.normpath(
@@ -227,6 +288,7 @@ def __eq__(self, other):
227288
)
228289

229290
def __ne__(self, other):
291+
"""Check that two server contexts are not equal."""
230292
return not self == other
231293

232294

@@ -266,8 +328,9 @@ class AvailableServerContexts:
266328

267329

268330
def set_default_server_context(context=AvailableServerContexts.premium) -> None:
269-
"""Sets this context as default for any new server. Also applies it to
270-
the global server if it is running as Entry and requested context is Premium.
331+
"""Set this context as default for any new server.
332+
333+
Also applies it to the global server if it is running as Entry and requested context is Premium.
271334
272335
The context enables to choose whether DPF capabilities requiring a license checkout are allowed.
273336

0 commit comments

Comments
 (0)