Skip to content

Commit 30e411f

Browse files
updates in the DataSources api reference
1 parent 74f87c4 commit 30e411f

File tree

1 file changed

+3
-83
lines changed

1 file changed

+3
-83
lines changed

src/ansys/dpf/core/data_sources.py

Lines changed: 3 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -138,32 +138,7 @@ def __init__(
138138
def set_result_file_path(
139139
self, filepath: Union[str, os.PathLike], key: Optional[str] = ""
140140
) -> None:
141-
"""Set the main result file path to the data sources.
142-
143-
Parameters
144-
----------
145-
filepath :
146-
Path to the result file.
147-
key :
148-
Extension of the file, which is used as a key for choosing the correct
149-
plugin when a result is requested by an operator. The default is ``""``,
150-
in which case the key is found directly.
151-
152-
Examples
153-
--------
154-
Create a DataSources object and set the result file path.
155-
156-
>>> from ansys.dpf import core as dpf
157-
>>>
158-
>>> # Create the DataSources object
159-
>>> my_data_sources = dpf.DataSources()
160-
>>> # Define the path where the main result file can be found
161-
>>> my_data_sources.set_result_file_path(filepath='/tmp/file.rst', key='rst')
162-
>>> # Get the path to the main result file
163-
>>> my_data_sources.result_files
164-
['/tmp/file.rst']
165-
166-
"""
141+
"""Set the main result file path to the data sources."""
167142
extension = os.path.splitext(filepath)[1]
168143
# Handle .res files from CFX
169144
if key == "" and extension == ".res":
@@ -182,37 +157,7 @@ def set_result_file_path(
182157

183158
@staticmethod
184159
def guess_result_key(filepath: str) -> str:
185-
"""Guess result key for files without an explicit file extension.
186-
187-
Parameters
188-
----------
189-
filepath :
190-
Path to the file.
191-
192-
Returns
193-
-------
194-
str :
195-
Extension key name
196-
197-
Examples
198-
--------
199-
Gives the result key for the result file of the given path
200-
201-
>>> from ansys.dpf import core as dpf
202-
>>> from ansys.dpf.core import examples
203-
>>>
204-
>>> # Create the DataSources object
205-
>>> my_data_sources = dpf.DataSources()
206-
>>> # Download the result files
207-
>>> path = examples.download_d3plot_beam()
208-
>>> # Define the path where the main result file can be found
209-
>>> my_data_sources.set_result_file_path(filepath=path[0])
210-
>>> # Define the extension key for the file in the given path
211-
>>> my_file_key = my_data_sources.guess_result_key(filepath=path[0])
212-
>>> print(my_file_key)
213-
d3plot
214-
215-
"""
160+
"""Guess result key for files without an explicit file extension."""
216161
result_keys = ["d3plot", "binout"]
217162
base_name = os.path.basename(filepath)
218163
# Handle files without extension
@@ -237,32 +182,7 @@ def guess_second_key(filepath: str) -> str:
237182
def set_domain_result_file_path(
238183
self, path: Union[str, os.PathLike], domain_id: int, key: Optional[str] = None
239184
) -> None:
240-
"""Set a result file path by domain.
241-
242-
This method is used to handle files created by a distributed solve.
243-
244-
Parameters
245-
----------
246-
path :
247-
Path to the file.
248-
domain_id :
249-
Domain ID for the distributed files.
250-
key :
251-
Key to associate to the file.
252-
253-
Examples
254-
--------
255-
Set the main result file path to the data sources in their respective domains.
256-
257-
>>> from ansys.dpf import core as dpf
258-
>>>
259-
>>> # Create the DataSources object
260-
>>> my_data_sources = dpf.DataSources()
261-
>>> # Define the path where the main result data can be found and specify its domain
262-
>>> my_data_sources.set_domain_result_file_path(path='/tmp/file0.rst', key='rst', domain_id=0)
263-
>>> my_data_sources.set_domain_result_file_path(path='/tmp/file1.rst', key='rst', domain_id=1)
264-
265-
"""
185+
"""Set a result file path by domain."""
266186
if key:
267187
self._api.data_sources_set_domain_result_file_path_with_key_utf8(
268188
self, str(path), key, domain_id

0 commit comments

Comments
 (0)