Skip to content

Commit e766370

Browse files
Fix line lengths for comments and docstrings (#78)
* Fix line lengths * Update flake8 config * Apply suggestions from code review Co-authored-by: Alex Kaszynski <[email protected]> * Remove random test * Apply suggestions from code review Co-authored-by: Alex Kaszynski <[email protected]> * Update ansys/dpf/core/time_freq_support.py Co-authored-by: Alex Kaszynski <[email protected]> * Remove whitespace * Fix failing doc test * Fix field doc string * Move noqa to next line for docstring * Remove noqa to test docstring * Ignore docstring output line lengths * Fix model displacement Co-authored-by: Alex Kaszynski <[email protected]>
1 parent 9e68753 commit e766370

26 files changed

+197
-84
lines changed

.flake8

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[flake8]
2-
# To be added once code is refactored: E501
32
exclude = venv, ansys/dpf/core/operators
4-
select = W191, W391, E115, E117, E122, E124, E125, E301, W291, W293, E225, E231, E303, F401, F403
3+
select = W191, W391, E115, E117, E122, E124, E125, E301, W291, W293, E225, E231, E303, E501, F401, F403
54
per-file-ignores = __init__.py:F401,F403
65
count = True
76
max-complexity = 10

ansys/dpf/core/aeneid.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def start_server_using_service_manager(): # pragma: no cover
1414
)
1515
else:
1616
raise ValueError(
17-
"Module grpc_interceptor_headers is missing. To use Service Manager, install it using pip install grpc_interceptor_headers."
17+
"Module grpc_interceptor_headers is missing. To use Service "
18+
"Manager, install it using pip install grpc_interceptor_headers."
1819
)
1920

2021
service_manager_url = f"http://{LOCALHOST}:8089/v1"

ansys/dpf/core/common.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,32 @@ def __write_enum_doc__(enum, intro=None):
5151
types = Enum("types", names)
5252
types.__doc__ = __write_enum_doc__(
5353
types,
54-
"The ``'types'`` enum contains the available types passed through operators and workflows to DPF.",
54+
(
55+
"The ``'types'`` enum contains the available types passed "
56+
"through operators and workflows to DPF."
57+
),
5558
)
5659

5760
names = [(m.lower(), num) for m, num in base_pb2.Nature.items()]
5861
natures = Enum("natures", names)
5962
natures.__doc__ = __write_enum_doc__(
6063
natures,
61-
"The ``'natures'`` enum contains the dimensionality types.\n It can be used to create a field of a given dimensionality.",
64+
(
65+
"The ``'natures'`` enum contains the dimensionality types.\n "
66+
"It can be used to create a field of a given dimensionality."
67+
),
6268
)
6369

6470

6571
names = [(m.lower(), num - 1) for m, num in field_definition_pb2.ShellLayers.items()]
6672
shell_layers = Enum("shell_layers", names)
6773
shell_layers.__doc__ = __write_enum_doc__(
6874
shell_layers,
69-
"The ``'shell_layers'`` enum contains the available order of shell layers (or lack of shell layers) that defines how the field's data is ordered.",
75+
(
76+
"The ``'shell_layers'`` enum contains the available order of "
77+
"shell layers (or lack of shell layers) that defines how the "
78+
"field's data is ordered."
79+
),
7080
)
7181

7282

ansys/dpf/core/core.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ def _description(dpf_entity_message, server=None):
247247
248248
Parameters
249249
----------
250-
dpf_entity_message : core.Operator._message, core.Workflow._message, core.Scoping._message, core.Field._message,
251-
core.FieldContainer._message, core.MeshedRegion._message...
250+
dpf_entity_message : core.Operator._message, core.Workflow._message,
251+
core.Scoping._message, core.Field._message,
252+
core.FieldContainer._message, core.MeshedRegion._message
252253
253254
server : server.DPFServer, optional
254255
Server with channel connected to the remote or local instance. When
@@ -313,7 +314,8 @@ def _connect(self, timeout=5):
313314

314315
if not state._matured:
315316
raise IOError(
316-
f"Unable to connect to DPF instance at {self._server()._input_ip} {self._server()._input_port}"
317+
f"Unable to connect to DPF instance at {self._server()._input_ip} "
318+
f"{self._server()._input_port}"
317319
)
318320

319321
return stub
@@ -419,7 +421,8 @@ def _description(self, dpf_entity_message):
419421
420422
Parameters
421423
----------
422-
dpf_entity_message : core.Operator._message, core.Workflow._message, core.Scoping._message, core.Field._message,
424+
dpf_entity_message : core.Operator._message, core.Workflow._message,
425+
core.Scoping._message, core.Field._message,
423426
core.FieldContainer._message, core.MeshedRegion._message...
424427
425428
Returns

ansys/dpf/core/cyclic_support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ def base_elements_scoping(self, stage_num=0) -> int:
167167
)
168168

169169
def sectors_set_for_expansion(self, stage_num=0) -> int:
170-
"""Retrieve a sector's scoping of the already expanded results and mesh or the list of sectors that will
171-
be expanded by default.
170+
"""Retrieve a sector's scoping of the already expanded results
171+
and mesh or the list of sectors that will be expanded by default.
172172
173173
A sector's scoping starts from 0, with the maximum equal to num_sectors-1.
174174

ansys/dpf/core/dpf_operator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ def connect(self, pin, inpt, pin_out=0):
111111
----------
112112
pin : int
113113
Number of the input pin.
114-
inpt : str, int, double, bool, list of int, list of doubles, Field, FieldsContainer, Scoping, ScopingsContainer, MeshedRegion, MeshesContainer, DataSources, Operator
114+
inpt : str, int, double, bool, list of int, list of doubles,
115+
Field, FieldsContainer, Scoping, ScopingsContainer, MeshedRegion,
116+
MeshesContainer, DataSources, Operator
115117
Object to connect to.
116118
pin_out : int, optional
117119
If the input is an operator, the output pin of the input operator. The

ansys/dpf/core/element_descriptor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ElementDescriptor:
3939
>>> from ansys.dpf import core as dpf
4040
>>> descriptor = dpf.ElementDescriptor(10, "Linear 4-nodes Tetrahedron", "tet4", "solid", 4, 0, 4, True, False, False, False)
4141
42-
"""
42+
""" # noqa: E501
4343

4444
def __init__(
4545
self,

ansys/dpf/core/elements.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
class Element:
1717
"""Contains all properties of an element of a mesh.
1818
19-
The element is created from the :class:`MeshedRegion <ansys.dpf.core.meshed_region.MeshedRegion>` class.
19+
The element is created from the
20+
:class:`MeshedRegion <ansys.dpf.core.meshed_region.MeshedRegion>` class.
2021
Properties include the element ID, index, type, shape, and connectivity.
2122
2223
Parameters
@@ -136,7 +137,8 @@ def type(self) -> int:
136137
Returns
137138
-------
138139
int
139-
Type of the element. For more information, see :class:`ansys.dpf.core.elements.element_types`.
140+
Type of the element. For more information, see
141+
:class:`ansys.dpf.core.elements.element_types`.
140142
141143
Examples
142144
--------

ansys/dpf/core/examples/downloads.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def download_msup_files_to_dict() -> dict:
250250
>>> paths
251251
{'rfrq': 'C:\\Users\\user\\AppData\\Local\\ansys-dpf-core\\ansys-dpf-core\\examples\\msup\\file.rfrq',
252252
'mode': 'C:\\Users\\user\\AppData\\Local\\ansys-dpf-core\\ansys-dpf-core\\examples\\msup\\file.mode',
253-
'rst': 'C:\\Users\\user\\AppData\\Local\\ansys-dpf-core\\ansys-dpf-core\\examples\\msup\\file.rst'}
253+
'rst': 'C:\\Users\\user\\AppData\\Local\\ansys-dpf-core\\ansys-dpf-core\\examples\\msup\\file.rst'} # noqa: E501
254254
255255
"""
256256
return {
@@ -280,7 +280,7 @@ def download_distributed_files() -> dict:
280280
>>> paths = examples.download_distributed_files()
281281
>>> paths
282282
{0: 'C:\\Users\\user\\AppData\\Local\\ansys-dpf-core\\ansys-dpf-core\\examples\\distributed\\file0.rst',
283-
1: 'C:\\Users\\user\\AppData\\Local\\ansys-dpf-core\\ansys-dpf-core\\examples\\distributed\\file1.rst'}
283+
1: 'C:\\Users\\user\\AppData\\Local\\ansys-dpf-core\\ansys-dpf-core\\examples\\distributed\\file1.rst'} # noqa: E501
284284
285285
"""
286286
return {
@@ -309,7 +309,7 @@ def download_fluent_files() -> dict:
309309
>>> paths = examples.download_fluent_files()
310310
>>> paths
311311
{'cas': 'C:\\Users\\cbellot\\AppData\\Local\\ansys-dpf-core\\ansys-dpf-core\\examples\\fluent\\FFF.cas.h5',
312-
'dat': 'C:\\Users\\cbellot\\AppData\\Local\\ansys-dpf-core\\ansys-dpf-core\\examples\\fluent\\FFF.dat.h5'}
312+
'dat': 'C:\\Users\\cbellot\\AppData\\Local\\ansys-dpf-core\\ansys-dpf-core\\examples\\fluent\\FFF.dat.h5'} # noqa: E501
313313
314314
"""
315315
return {
@@ -319,15 +319,17 @@ def download_fluent_files() -> dict:
319319

320320

321321
def download_extrapolation_3d_result() -> dict:
322-
"""Download example static results of reference and integrated points for extrapolation of 3d-element and return return the dictionary of 2 download paths.
322+
"""Download example static results of reference and integrated points
323+
for extrapolation of 3d-element and return return the dictionary of 2 download paths.
323324
324325
Examples files are downloaded to a persistent cache to avoid
325326
re-downloading the same file twice.
326327
327328
Returns
328329
-------
329330
dict
330-
containing path to the example file of ref and path to the example file of integrated points.
331+
containing path to the example file of ref and path to the example
332+
file of integrated points.
331333
332334
Examples
333335
--------
@@ -336,7 +338,10 @@ def download_extrapolation_3d_result() -> dict:
336338
>>> from ansys.dpf.core import examples
337339
>>> dict = examples.download_extrapolation_ref_result
338340
>>> dict
339-
{'file_ref': 'C:/Users/user/AppData/local/temp/file_ref.rst', 'file_integrated': 'C:/Users/user/AppData/local/temp/file.rst'}
341+
{
342+
'file_ref': 'C:/Users/user/AppData/local/temp/file_ref.rst',
343+
'file_integrated': 'C:/Users/user/AppData/local/temp/file.rst'
344+
}
340345
341346
"""
342347
dict = {
@@ -348,15 +353,17 @@ def download_extrapolation_3d_result() -> dict:
348353

349354

350355
def download_extrapolation_2d_result() -> dict:
351-
"""Download example static results of reference and integrated points for extrapolation of 2d-element and return the dictionary of 2 download paths.
356+
"""Download example static results of reference and integrated points
357+
for extrapolation of 2d-element and return the dictionary of 2 download paths.
352358
353359
Examples files are downloaded to a persistent cache to avoid
354360
re-downloading the same file twice.
355361
356362
Returns
357363
-------
358364
dict
359-
containing path to the example file of ref and path to the example file of integrated points.
365+
Contains path to the example file of ref and path to the example
366+
file of integrated points.
360367
361368
Examples
362369
--------
@@ -365,7 +372,10 @@ def download_extrapolation_2d_result() -> dict:
365372
>>> from ansys.dpf.core import examples
366373
>>> dict = examples.download_extrapolation_ref_result
367374
>>> dict
368-
{'file_ref': 'C:/Users/user/AppData/local/temp/extrapolate_2d_ref.rst', 'file_integrated': 'C:/Users/user/AppData/local/temp/extrapolate_2d.rst'}
375+
{
376+
'file_ref': 'C:/Users/user/AppData/local/temp/extrapolate_2d_ref.rst',
377+
'file_integrated': 'C:/Users/user/AppData/local/temp/extrapolate_2d.rst'
378+
}
369379
370380
"""
371381
dict = {

ansys/dpf/core/field.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ class Field(_FieldBase):
2020
This can be evaluated data from the :class:`Operator <ansys.dpf.core.Operator>` class
2121
or created by a factory and directly by an instance of this class.
2222
23-
A field's data is always associated to its scoping (entities associated to each value)
24-
and support (subset of the model where the data is), making the field a self-describing piece of data.
23+
A field's data is always associated to its scoping (entities
24+
associated to each value) and support (subset of the model where the
25+
data is), making the field a self-describing piece of data.
2526
2627
Parameters
2728
----------
@@ -140,7 +141,7 @@ def as_local_field(self):
140141
(array([[0.3, 0.6, 0.9],
141142
[0.3, 0.6, 0.9]]), [[0.30000000000000004, 0.6000000000000001, 0.8999999999999999], [0.30000000000000004, 0.6000000000000001, 0.8999999999999999]])
142143
143-
"""
144+
""" # noqa: E501
144145
return _LocalField(self)
145146

146147
@property
@@ -413,7 +414,8 @@ def _get_meshed_region(self):
413414
return meshed_region.MeshedRegion(mesh=message, server=self._server)
414415
except:
415416
raise RuntimeError(
416-
"The field's support is not a mesh. Try to retrieve the time frequency support."
417+
"The field's support is not a mesh. "
418+
"Try to retrieve the time frequency support."
417419
)
418420

419421
def _get_time_freq_support(self):
@@ -653,7 +655,7 @@ class _LocalField(_LocalFieldBase, Field):
653655
(array([[0.3, 0.6, 0.9],
654656
[0.3, 0.6, 0.9]]), [[0.30000000000000004, 0.6000000000000001, 0.8999999999999999], [0.30000000000000004, 0.6000000000000001, 0.8999999999999999]])
655657
656-
"""
658+
""" # noqa: E501
657659

658660
def __init__(self, field):
659661
super().__init__(field)

0 commit comments

Comments
 (0)