Skip to content

Commit 7d5aa0b

Browse files
authored
Black reformatting (#34)
* Reformat with black to handle line length issues * Add line length check to config
1 parent 186330a commit 7d5aa0b

40 files changed

+1446
-649
lines changed

.ci/display_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
import pyvista
33
from pyvista.plotting import system_supports_plotting
44

5-
print('system_supports_plotting', system_supports_plotting())
5+
print("system_supports_plotting", system_supports_plotting())
66
pyvista.OFF_SCREEN = True
77
pyvista.plot(pyvista.Sphere())

.flake8

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

ansys/dpf/post/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
1717
"""
1818

19-
#dpf.core.start_local_server()
19+
# dpf.core.start_local_server()

ansys/dpf/post/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
version_info = 0, 2, 0
44

55
# Nice string for the version
6-
__version__ = '.'.join(map(str, version_info))
6+
__version__ = ".".join(map(str, version_info))

ansys/dpf/post/common.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# shell_bottom = 6
2020

2121

22-
class Grouping():
22+
class Grouping:
2323
"""Class with Enum inheritance. Must be used to
2424
describe a grouping command when the API allows it.
2525
@@ -29,18 +29,20 @@ class Grouping():
2929
>>> solution = post.solution("file.rst")
3030
>>> disp = solution.elemental_stress(element_shape = post.grouping.by_el_shape)
3131
"""
32+
3233
by_el_shape = "elshape"
3334
by_material = "mat"
3435
by_body = "body"
3536

3637

37-
class _AvailableKeywords():
38+
class _AvailableKeywords:
3839
"""Contains all the keywords that can be used inside of
3940
a method from a post.solution(file_path) object.
4041
4142
In order to view the complete list of available keywords, use:
4243
post.print_available_keywords()
4344
"""
45+
4446
location = "location"
4547
node_scoping = "node_scoping"
4648
element_scoping = "element_scoping"
@@ -56,43 +58,49 @@ class _AvailableKeywords():
5658
def __str__(self):
5759
txt = ""
5860
for attr in dir(_AvailableKeywords):
59-
if not attr.startswith("__") and not attr.startswith("_") and not callable(getattr(_AvailableKeywords, attr)):
61+
if (
62+
not attr.startswith("__")
63+
and not attr.startswith("_")
64+
and not callable(getattr(_AvailableKeywords, attr))
65+
):
6066
txt += attr
6167
txt += ": "
6268
txt += self._description_mapping(attr)
6369
txt += "\n"
6470
return txt
6571

6672
def _description_mapping(self, attr_name):
67-
if (attr_name == self.location):
73+
if attr_name == self.location:
6874
return "str. Use post.locations.(...) as helper."
69-
if (attr_name == self.node_scoping):
75+
if attr_name == self.node_scoping:
7076
return "list, int or dpf.core.Scoping"
71-
if (attr_name == self.element_scoping):
77+
if attr_name == self.element_scoping:
7278
return "list, int or dpf.core.Scoping"
73-
if (attr_name == self.time_scoping):
79+
if attr_name == self.time_scoping:
7480
return "list, int or dpf.core.Scoping"
75-
if (attr_name == self.named_selection):
81+
if attr_name == self.named_selection:
7682
return "str. Name of named_selection."
77-
if (attr_name == self.time):
83+
if attr_name == self.time:
7884
return "float"
79-
if (attr_name == self.set):
85+
if attr_name == self.set:
8086
return "int"
81-
if (attr_name == self.mapdl_grouping):
87+
if attr_name == self.mapdl_grouping:
8288
return "int. Write 186 to get mapdl_elements solid_186."
83-
if (attr_name == self.grouping):
89+
if attr_name == self.grouping:
8490
return "str. Use post.grouping.(...) as helper."
8591

8692

87-
class _AnalysisType():
93+
class _AnalysisType:
8894
"""Contains Python analysis type names. For developers usage."""
95+
8996
static = "static"
9097
modal = "modal"
9198
harmonic = "harmonic"
9299
transient = "transient"
93100

94101

95-
class _PhysicsType():
102+
class _PhysicsType:
96103
"""Contains Python physics type names. For developers usage."""
104+
97105
mecanic = "mecanic"
98106
thermal = "thermal"

ansys/dpf/post/displacement.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
from ansys.dpf.core import locations
55
from ansys.dpf.post.errors import NodalLocationError
66

7+
78
class Displacement(Vector):
89
"""Defines the displacement object, that is a vector object."""
10+
911
def __init__(self, **kwargs):
1012
super().__init__(**kwargs)
1113
self._operator_name = "U"
@@ -22,6 +24,7 @@ def __str__(self):
2224

2325
class ComplexDisplacement(ComplexVector):
2426
"""Defines the complex displacement object, that is a vector object."""
27+
2528
def __init__(self, **kwargs):
2629
super().__init__(**kwargs)
2730
self._operator_name = "U"

ansys/dpf/post/dpf_solution.py

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
class DpfSolution:
3333
"""Main class of post result API."""
34+
3435
def __init__(self, data_sources, model):
3536
"""Initialization of the solution using data_sources
3637
and dpf.core.Model object."""
@@ -67,8 +68,11 @@ def _check_nodal_location(self, **kwargs):
6768
raise NodalLocationError()
6869

6970
def __str__(self):
70-
txt = '%s solution object.' % self._model.metadata.result_info.analysis_type.capitalize() +\
71-
'\n\n\nData Sources\n------------------------------\n'
71+
txt = (
72+
"%s solution object."
73+
% self._model.metadata.result_info.analysis_type.capitalize()
74+
+ "\n\n\nData Sources\n------------------------------\n"
75+
)
7276
ds_str = self._data_sources.__str__()
7377
txt += ds_str
7478
txt += "\n\n"
@@ -77,12 +81,11 @@ def __str__(self):
7781

7882

7983
class DpfMecanicSolution(DpfSolution):
80-
8184
def __init__(self, data_sources, model):
8285
super().__init__(data_sources, model)
8386
self.misc = MecanicMisc(model, data_sources)
8487

85-
#result classes
88+
# result classes
8689
def stress(self, **kwargs):
8790
"""Returns a stress object from which it is possible to get ResultData.
8891
@@ -113,7 +116,9 @@ def elastic_strain(self, **kwargs):
113116
>>> solution = post.load_solution(file.rst)
114117
>>> elastic_strain = solution.elastic_strain(node_scoping = [1, 43])
115118
"""
116-
return ElasticStrain(data_sources=self._data_sources, model=self._model, **kwargs)
119+
return ElasticStrain(
120+
data_sources=self._data_sources, model=self._model, **kwargs
121+
)
117122

118123
def plastic_strain(self, **kwargs):
119124
"""Returns a plastic strain object from which it is possible to get ResultData.
@@ -129,7 +134,9 @@ def plastic_strain(self, **kwargs):
129134
>>> solution = post.load_solution(file.rst)
130135
>>> plastic_strain = solution.plastic_strain(node_scoping = [1, 43])
131136
"""
132-
return PlasticStrain(data_sources=self._data_sources, model=self._model, **kwargs)
137+
return PlasticStrain(
138+
data_sources=self._data_sources, model=self._model, **kwargs
139+
)
133140

134141
def displacement(self, **kwargs):
135142
"""Returns a displacement object from which it is possible to get ResultData.
@@ -145,7 +152,9 @@ def displacement(self, **kwargs):
145152
>>> solution = post.load_solution(file.rst)
146153
>>> displacement = solution.displacement(node_scoping = [1, 43])
147154
"""
148-
return Displacement(data_sources=self._data_sources, model=self._model, **kwargs)
155+
return Displacement(
156+
data_sources=self._data_sources, model=self._model, **kwargs
157+
)
149158

150159
def structural_temperature(self, **kwargs):
151160
"""Returns a temperature object from which it is possible to get ResultData.
@@ -161,11 +170,14 @@ def structural_temperature(self, **kwargs):
161170
>>> solution = post.load_solution(file.rst)
162171
>>> temperature = solution.structural_temperature(node_scoping = [1, 43])
163172
"""
164-
return StructuralTemperature(data_sources=self._data_sources, model=self._model, **kwargs)
173+
return StructuralTemperature(
174+
data_sources=self._data_sources, model=self._model, **kwargs
175+
)
165176

166177

167178
class DpfMecanicComplexSolution(DpfSolution):
168179
"""Main class of post solution if the analysis gives complex solution (Modal, Harmonic)."""
180+
169181
def __init__(self, data_sources, model):
170182
super().__init__(data_sources, model)
171183
self.misc = ComplexMecanicMisc(model, data_sources)
@@ -185,7 +197,7 @@ def has_complex_result(self):
185197
tfq_sup = self._model.metadata.time_freq_support
186198
if not tfq_sup:
187199
return False
188-
if (tfq_sup.complex_frequencies == None):
200+
if tfq_sup.complex_frequencies == None:
189201
return False
190202
return True
191203

@@ -203,7 +215,9 @@ def displacement(self, **kwargs):
203215
>>> solution = post.load_solution(file.rst)
204216
>>> displacement = solution.displacement(node_scoping = [1, 43])
205217
"""
206-
return ComplexDisplacement(data_sources=self._data_sources, model=self._model, **kwargs)
218+
return ComplexDisplacement(
219+
data_sources=self._data_sources, model=self._model, **kwargs
220+
)
207221

208222
def structural_temperature(self, **kwargs):
209223
"""Returns a temperature object from which it is possible to get ResultData.
@@ -219,7 +233,9 @@ def structural_temperature(self, **kwargs):
219233
>>> solution = post.load_solution(file.rst)
220234
>>> temperature = solution.structural_temperature(node_scoping = [1, 43])
221235
"""
222-
return ComplexStructuralTemperature(data_sources=self._data_sources, model=self._model, **kwargs)
236+
return ComplexStructuralTemperature(
237+
data_sources=self._data_sources, model=self._model, **kwargs
238+
)
223239

224240
def plastic_strain(self, **kwargs):
225241
"""Returns a plastic strain object from which it is possible to get ResultData.
@@ -235,7 +251,9 @@ def plastic_strain(self, **kwargs):
235251
>>> solution = post.load_solution(file.rst)
236252
>>> plastic_strain = solution.plastic_strain(node_scoping = [1, 43])
237253
"""
238-
return ComplexPlasticStrain(data_sources=self._data_sources, model=self._model, **kwargs)
254+
return ComplexPlasticStrain(
255+
data_sources=self._data_sources, model=self._model, **kwargs
256+
)
239257

240258
def elastic_strain(self, **kwargs):
241259
"""Returns an elastic strain object from which it is possible to get ResultData.
@@ -251,7 +269,9 @@ def elastic_strain(self, **kwargs):
251269
>>> solution = post.load_solution(file.rst)
252270
>>> elastic_strain = solution.elastic_strain(node_scoping = [1, 43])
253271
"""
254-
return ComplexElasticStrain(data_sources=self._data_sources, model=self._model, **kwargs)
272+
return ComplexElasticStrain(
273+
data_sources=self._data_sources, model=self._model, **kwargs
274+
)
255275

256276
def stress(self, **kwargs):
257277
"""Returns a stress object from which it is possible to get ResultData.
@@ -267,14 +287,17 @@ def stress(self, **kwargs):
267287
>>> solution = post.load_solution(file.rst)
268288
>>> stress = solution.stress(node_scoping = [1, 43])
269289
"""
270-
return ComplexStress(data_sources=self._data_sources, model=self._model, **kwargs)
290+
return ComplexStress(
291+
data_sources=self._data_sources, model=self._model, **kwargs
292+
)
271293

272294

273295
class DpfThermalSolution(DpfSolution):
274296
"""Main class of post solution if thermal analysis."""
297+
275298
def __init__(self, data_sources, model):
276299
super().__init__(data_sources, model)
277-
#self.misc = ThermalMisc(model, data_sources)
300+
# self.misc = ThermalMisc(model, data_sources)
278301

279302
def __str__(self):
280303
txt = super().__str__()
@@ -330,7 +353,9 @@ def electric_potential(self, **kwargs):
330353
>>> ep = solution.electric_potential(node_scoping = [1, 43])
331354
"""
332355
self._check_nodal_location(**kwargs)
333-
return ElectricPotential(data_sources=self._data_sources, model=self._model, **kwargs)
356+
return ElectricPotential(
357+
data_sources=self._data_sources, model=self._model, **kwargs
358+
)
334359

335360
def electric_field(self, **kwargs):
336361
"""Returns an electric field object from which it is possible to get ResultData.
@@ -346,4 +371,6 @@ def electric_field(self, **kwargs):
346371
>>> solution = post.load_solution(file.rst)
347372
>>> ef = solution.electric_field(node_scoping = [1, 43])
348373
"""
349-
return ElectricField(data_sources=self._data_sources, model=self._model, **kwargs)
374+
return ElectricField(
375+
data_sources=self._data_sources, model=self._model, **kwargs
376+
)

ansys/dpf/post/electric_results.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77

88
class ElectricField(Vector):
99
"""Defines the temperature object for thermal/electric analysis, that is a scalar object."""
10+
1011
def __init__(self, **kwargs):
1112
super().__init__(**kwargs)
1213
self._operator_name = "EF"
1314

14-
#disable element scoping
15+
# disable element scoping
1516
if _AvailableKeywords.element_scoping in kwargs:
16-
raise Exception("Element scoping is not available with thermal/electric results.")
17+
raise Exception(
18+
"Element scoping is not available with thermal/electric results."
19+
)
1720
self.definition._Definition__element_scoping_locked = True
1821

1922
def __str__(self):
@@ -25,13 +28,16 @@ def __str__(self):
2528

2629
class ElectricPotential(Scalar):
2730
"""Defines the temperature object for thermal/electric analysis, that is a scalar object."""
31+
2832
def __init__(self, **kwargs):
2933
super().__init__(**kwargs)
3034
self._operator_name = "VOLT"
3135

32-
#disable element scoping
36+
# disable element scoping
3337
if _AvailableKeywords.element_scoping in kwargs:
34-
raise Exception("Element scoping is not available with thermal/electric results.")
38+
raise Exception(
39+
"Element scoping is not available with thermal/electric results."
40+
)
3541
self.definition._Definition__element_scoping_locked = True
3642

3743
def __str__(self):

ansys/dpf/post/errors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""DPF-Post specific errors"""
22

3+
34
class NodalLocationError(ValueError):
4-
"""Raised when attempting to """
5+
"""Raised when attempting to"""
56

67
def __init__(self, msg="The location must be nodal."):
78
ValueError.__init__(self, msg)

0 commit comments

Comments
 (0)