Skip to content

Commit 15b624e

Browse files
changes in the add_file path and add_domain_file_path functions
1 parent 5b5f306 commit 15b624e

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

src/ansys/dpf/core/data_sources.py

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -301,30 +301,44 @@ def set_domain_result_file_path(
301301
else:
302302
self._api.data_sources_set_domain_result_file_path_utf8(self, str(path), domain_id)
303303

304-
def add_file_path(self, filepath, key="", is_domain: bool = False, domain_id=0):
305-
"""Add a file path to the data sources.
304+
def add_file_path(
305+
self,
306+
filepath: Union[str, os.PathLike],
307+
key: Optional[str] = "",
308+
is_domain: Optional[bool] = False,
309+
domain_id: Optional[int] = 0,
310+
) -> None:
311+
"""Add an acccesory file path to the data sources.
306312
307313
Files not added as result files are accessory files, which contain accessory
308314
information not present in the result files.
309315
310316
Parameters
311317
----------
312-
filepath : str or os.PathLike object
318+
filepath
313319
Path of the file.
314-
key : str, optional
320+
key
315321
Extension of the file, which is used as a key for choosing the correct
316322
plugin when a result is requested by an operator. The default is ``""``,
317323
in which case the key is found directly.
318-
is_domain: bool, optional
324+
is_domain
319325
Whether the file path is the domain path. The default is ``False``.
320-
domain_id: int, optional
326+
domain_id
321327
Domain ID for the distributed files. The default is ``0``. For this
322328
parameter to be taken into account, ``domain_path=True`` must be set.
329+
323330
Examples
324331
--------
332+
Add an accessory file to the DataSources object
333+
325334
>>> from ansys.dpf import core as dpf
326-
>>> data_sources = dpf.DataSources()
327-
>>> data_sources.add_file_path('/tmp/ds.dat')
335+
>>>
336+
>>> # Create the DataSources object
337+
>>> my_data_sources = dpf.DataSources()
338+
>>> # Define the path where the main result file can be found
339+
>>> my_data_sources.set_result_file_path(filepath='/tmp/file.cas', key='cas')
340+
>>> # Add the additional result file to the DataSources object
341+
>>> my_data_sources.add_file_path(filepath='/tmp/ds.dat', key='dat')
328342
329343
"""
330344
# The filename needs to be a fully qualified file name
@@ -344,8 +358,10 @@ def add_file_path(self, filepath, key="", is_domain: bool = False, domain_id=0):
344358
else:
345359
self._api.data_sources_add_file_path_with_key_utf8(self, str(filepath), key)
346360

347-
def add_domain_file_path(self, filepath, key, domain_id):
348-
"""Add a file path to the data sources.
361+
def add_domain_file_path(
362+
self, filepath: Union[str, os.PathLike], key: str, domain_id: int
363+
) -> None:
364+
"""Add a file path to the data sources in the given domain.
349365
350366
Files not added as result files are accessory files, which contain accessory
351367
information not present in the result files.
@@ -361,9 +377,16 @@ def add_domain_file_path(self, filepath, key, domain_id):
361377
Domain ID for the distributed files.
362378
Examples
363379
--------
380+
Add an accessory file to its domain
381+
364382
>>> from ansys.dpf import core as dpf
365-
>>> data_sources = dpf.DataSources()
366-
>>> data_sources.add_domain_file_path('/tmp/ds.dat', "dat", 1)
383+
>>>
384+
>>> # Create the DataSources object
385+
>>> my_data_sources = dpf.DataSources()
386+
>>> # Define the path where the main result data can be found and specify its domain
387+
>>> my_data_sources.set_domain_result_file_path(path='/tmp/ds.cas', key='cas', domain_id=1)
388+
>>> # Add the additional result data to the DataSources object and specify its domain
389+
>>> my_data_sources.add_domain_file_path(filepath='/tmp/ds.dat', key="dat", domain_id=1)
367390
368391
"""
369392
# The filename needs to be a fully qualified file name

0 commit comments

Comments
 (0)