Skip to content

Commit 294c764

Browse files
authored
feat: migrate to Ruff for code linting and formatting (#1727)
* feat: migrate linters and formaters to Ruff * fix: code style and spelling * fix: code style
1 parent c4c0e85 commit 294c764

File tree

104 files changed

+664
-439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+664
-439
lines changed

.ci/update_dpf_dependencies.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
It will update the current repo
1313
or the repo defined by the environment variable "ANSYSDPFCORE_ROOT" if it exists.
1414
"""
15+
1516
import os
1617
import glob
1718
import pathlib

.flake8

Lines changed: 0 additions & 9 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
1-
exclude: |
2-
(?x)^(
3-
doc/source/|
4-
src/ansys/dpf/core/operators/|
5-
examples_notebooks/|
6-
src/ansys/dpf/core/__init__.py|
7-
doc/styles/|
8-
src/ansys/dpf/gate/|
9-
src/ansys/dpf/gatebin/|
10-
src/ansys/grpc/dpf/|
11-
)
1+
exclude: >
2+
(?x)^(
3+
doc/source/
4+
|src/ansys/dpf/core/operators/
5+
|examples_notebooks/
6+
|src/ansys/dpf/core/__init__.py
7+
|doc/styles/
8+
|src/ansys/dpf/gate/
9+
|src/ansys/dpf/gatebin/
10+
|src/ansys/grpc/dpf/
11+
)
1212
repos:
1313

14-
- repo: https://github.com/psf/black
15-
rev: 24.4.2
14+
- repo: https://github.com/charliermarsh/ruff-pre-commit
15+
rev: v0.6.3
1616
hooks:
17-
- id: black
18-
19-
- repo: https://github.com/PyCQA/flake8
20-
rev: 7.0.0
21-
hooks:
22-
- id: flake8
17+
- id: ruff
18+
args: [ --fix ]
19+
- id: ruff-format
2320

2421
- repo: https://github.com/codespell-project/codespell
2522
rev: v2.3.0
2623
hooks:
2724
- id: codespell
28-
args: ["--ignore-words=ignore_words.txt"]
25+
args: ["--ignore-words=./doc/styles/Vocab/ANSYS/accept.txt"]
2926

3027
- repo: https://github.com/pre-commit/pre-commit-hooks
3128
rev: v4.6.0
@@ -36,6 +33,6 @@ repos:
3633

3734
# this validates our github workflow files
3835
- repo: https://github.com/python-jsonschema/check-jsonschema
39-
rev: 0.28.5
36+
rev: 0.29.2
4037
hooks:
41-
- id: check-github-workflows
38+
- id: check-github-workflows

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pydocstyle:
2121
@pydocstyle ansys.dpf.core
2222

2323
doctest-modules:
24-
@echo "Runnnig module doctesting"
24+
@echo "Running module doctesting"
2525
pytest -v --doctest-modules ansys.dpf.core
2626

2727
coverage:

conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Launch or connect to a persistent local DPF service to be shared in
44
pytest as a session fixture
55
"""
6+
67
import doctest
78
from doctest import DocTestRunner
89
from unittest import mock

doc/styles/Vocab/ANSYS/accept.txt

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,50 @@
11
ANSYS
2-
[Aa]nsys
3-
Abaqus
42
APIs
5-
[Cc]omponentization
6-
[Cc]ore
3+
Abaqus
74
CPython
85
DPF [Ss]erver
96
DPFArray
107
Entry
8+
GLTF
119
Gaussian
10+
IronPython
11+
MSUP
12+
Mises
13+
Premium
14+
Preview License Agreement
15+
PyDPF
16+
Pythonic
17+
Remotable
18+
Reusability
19+
Rz
20+
[Aa]nsys
21+
[Cc]omponentization
22+
[Cc]ore
23+
[Pp]ostprocessing
24+
[Pp]ython
25+
[Pp]yvista
26+
ans
27+
containter
1228
getters
1329
gltf
14-
GLTF
1530
grpcio
1631
hexa
17-
IronPython
32+
inpt
33+
mane
1834
matplotlib
19-
Mises
20-
MSUP
35+
mecanic
2136
numpy
37+
parm
2238
postprocess
23-
[Pp]ostprocessing
24-
Premium
25-
Preview License Agreement
39+
pres
2640
protobuf
2741
psutil
28-
PyDPF
29-
[Pp]ython
30-
Pythonic
31-
[Pp]yvista
3242
recursivity
33-
Remotable
34-
Reusability
35-
Rz
3643
scopings
3744
serializer
3845
setuptools
46+
socio-economic
3947
substep
48+
systyem
4049
tqdm
41-
von
50+
von

examples/01-transient_analyses/00-basic_transient.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
visualize the outputs.
1010
1111
"""
12+
1213
# Import the necessary modules
1314
import matplotlib.pyplot as plt
1415
import numpy as np

examples/01-transient_analyses/01-transient_easy_time_scoping.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
This example shows how to use a model's result to choose a time scoping.
99
1010
"""
11+
1112
import matplotlib.pyplot as plt
1213

1314
from ansys.dpf import core as dpf

examples/03-harmonic_analyses/00-multi_harmonic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using ``fft`` transformations.
99
1010
"""
11+
1112
import matplotlib.pyplot as pyplot
1213

1314
from ansys.dpf import core as dpf

examples/04-advanced/00-multistage_advanced_options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from a multi-stage cyclic analysis. It also shows how to use the cyclic support
99
for advanced postprocessing
1010
"""
11+
1112
from ansys.dpf import core as dpf
1213
from ansys.dpf.core import examples
1314
from ansys.dpf.core import operators as ops

examples/04-advanced/02-volume_averaged_stress.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
total volume.
1212
1313
"""
14+
1415
from ansys.dpf import core as dpf
1516
from ansys.dpf.core import examples
1617
from ansys.dpf.core import operators as ops

examples/04-advanced/13-manage_licensing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
For more information, see :ref:`ref_compatibility`.
2222
2323
"""
24+
2425
# Import necessary modules
2526
from ansys.dpf import core as dpf
2627
from ansys.dpf.core.core import errors

examples/05-file-IO/02-hdf5_serialize_and_read.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
res_deser_all_times_list = []
9696
h5_read_op = dpf.operators.serialization.hdf5dpf_custom_read()
9797
h5_read_op.inputs.streams.connect(h5_stream_prov_op.outputs)
98-
h5_read_op.inputs.time_scoping.connect(dpf.Scoping(ids = list(range(1,54)), location="time"))
98+
h5_read_op.inputs.time_scoping.connect(dpf.Scoping(ids=list(range(1, 54)), location="time"))
9999
for i, res_name in enumerate(result_names_on_all_time_steps):
100100
h5_read_op.inputs.result_name.connect(res_name)
101101
res_deser = h5_read_op.outputs.field_or_fields_container_as_fields_container()

examples/06-plotting/00-basic_plotting.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
screenshot="model_plot.png",
2424
title="Model",
2525
text="Model plot off",
26-
parallel_projection=True
26+
parallel_projection=True,
2727
)
2828

2929
# Notes:
@@ -81,14 +81,19 @@
8181
split_mesh_op.connect(7, mesh)
8282
split_mesh_op.connect(13, "mat")
8383
meshes_cont = split_mesh_op.get_output(0, dpf.types.meshes_container)
84-
meshes_cont.plot(title='Meshes Container', text='Meshes Container plot')
84+
meshes_cont.plot(title="Meshes Container", text="Meshes Container plot")
8585
# A fields_container can be given as input, with results on each part of our split mesh.
8686
disp_op = dpf.Operator("U")
8787
disp_op.connect(7, meshes_cont)
8888
ds = dpf.DataSources(examples.find_multishells_rst())
8989
disp_op.connect(4, ds)
9090
disp_fc = disp_op.outputs.fields_container()
91-
meshes_cont.plot(disp_fc, title='Meshes Container disp_fc', text='Meshes Container disp_fc plot')
91+
meshes_cont.plot(disp_fc, title="Meshes Container disp_fc", text="Meshes Container disp_fc plot")
9292
# Additional PyVista kwargs are supported, such as:
93-
meshes_cont.plot(off_screen=True, notebook=False, screenshot='meshes_cont_plot.png',
94-
title='Meshes Container', text='Meshes Container plot')
93+
meshes_cont.plot(
94+
off_screen=True,
95+
notebook=False,
96+
screenshot="meshes_cont_plot.png",
97+
title="Meshes Container",
98+
text="Meshes Container plot",
99+
)

examples/06-plotting/03-labels.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,5 @@
131131
# The three tuples in the list for the ``cpos`` argument represent the camera
132132
# position, focal point, and view respectively.
133133
plot.show_figure(
134-
show_axes=True,
135-
cpos=[(0.123, 0.095, 1.069), (-0.121, -0.149, 0.825), (0.0, 0.0, 1.0)]
134+
show_axes=True, cpos=[(0.123, 0.095, 1.069), (-0.121, -0.149, 0.825), (0.0, 0.0, 1.0)]
136135
)

examples/06-plotting/06-animate_results.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
shown with the arguments available.
99
1010
"""
11+
1112
from ansys.dpf import core as dpf
1213
from ansys.dpf.core import examples
1314

examples/09-averaging/00-compute_and_average.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474

7575

7676
def compute_von_mises_then_average(analysis):
77-
7877
# Create a model from the results of the simulation and retrieve its mesh
7978
model = dpf.Model(analysis)
8079
mesh = model.metadata.meshed_region
@@ -112,7 +111,6 @@ def compute_von_mises_then_average(analysis):
112111

113112

114113
def average_then_compute_von_mises(analysis):
115-
116114
# Creating the model from the results of the simulation
117115
model = dpf.Model(analysis)
118116
mesh = model.metadata.meshed_region
@@ -158,9 +156,7 @@ def average_then_compute_von_mises(analysis):
158156
print("Max stress when the stress averaging is done first: {:.2f} Pa".format(max2))
159157
print(
160158
"The maximum Von Mises stress value is {:.2f}% higher when \
161-
the averaging is done after the calculations.".format(
162-
diff
163-
)
159+
the averaging is done after the calculations.".format(diff)
164160
)
165161

166162
###############################################################################

examples/09-averaging/01-average_across_bodies.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,7 @@ def average_across_bodies(analysis):
259259
print("Max stress when averaging across bodies is deactivated: {:.2f} Pa".format(max_non_avg))
260260
print(
261261
"The maximum stress value when averaging across bodies is PERFORMED \
262-
is {:.2f}% LOWER than when it is NOT PERFORMED".format(
263-
diff
264-
)
262+
is {:.2f}% LOWER than when it is NOT PERFORMED".format(diff)
265263
)
266264

267265
###############################################################################

examples/10-mesh_operations/05-skin_extraction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
can be useful for specific results and for performance.
99
1010
"""
11+
1112
# Import necessary modules
1213
from ansys.dpf import core as dpf
1314
from ansys.dpf.core import examples

examples/10-mesh_operations/13-nodes_in_local_coordinate_system.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
The script below demonstrates the methodology using PyDPF.
1717
1818
"""
19+
1920
# Import necessary modules
2021
from ansys.dpf import core as dpf
2122
from ansys.dpf.core import examples

examples/11-cyclic-symmetry/01-modal_cyclic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
# extract Sx (use component selector and select the first component)
8181
comp_sel = dpf.operators.logic.component_selector_fc(scyc_op, 0)
8282

83-
# expand the displacements and get the resuls
83+
# expand the displacements and get the results
8484
fields = comp_sel.outputs.fields_container()
8585

8686
# plot the expanded result on the expanded mesh
@@ -105,7 +105,7 @@
105105
# extract Sy (use component selector and select the component 1)
106106
comp_sel = dpf.operators.logic.component_selector_fc(to_elemental, 1)
107107

108-
# expand the displacements and get the resuls
108+
# expand the displacements and get the results
109109
fields = comp_sel.outputs.fields_container()
110110

111111
# # plot the expanded result on the expanded mesh

examples/11-cyclic-symmetry/03-cyclic_multi_stage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
multi-stage cyclic analysis.
1010
1111
"""
12+
1213
from ansys.dpf import core as dpf
1314
from ansys.dpf.core import examples
1415

examples/12-fluids/03-fluids_isosurface.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,21 @@
8585

8686
vec_iso_values = [-153.6, -100.0, -50.0, 50.0, 100.0, 150.0, 200.0, 300.0, 361.8]
8787

88-
iso_surfaces_op = dpf.operators.mesh.iso_surfaces(field=P_S[0], mesh=whole_mesh, slice_surfaces=True,
89-
vector_iso_values=vec_iso_values)
88+
iso_surfaces_op = dpf.operators.mesh.iso_surfaces(
89+
field=P_S[0], mesh=whole_mesh, slice_surfaces=True, vector_iso_values=vec_iso_values
90+
)
9091

9192
iso_surfaces_meshes = iso_surfaces_op.outputs.meshes()
9293

9394
iso_surfaces_fields = iso_surfaces_op.outputs.fields_container()
9495

9596
for i in range(len(iso_surfaces_fields)):
9697
pl.add_field(
97-
field=iso_surfaces_fields[i], meshed_region=iso_surfaces_meshes[i], style="surface", show_edges=False,
98-
show_axes=True
98+
field=iso_surfaces_fields[i],
99+
meshed_region=iso_surfaces_meshes[i],
100+
style="surface",
101+
show_edges=False,
102+
show_axes=True,
99103
)
100104

101105
pl.show_figure(show_axes=True, cpos=c_pos_iso)

examples/14-lsdyna/00-lsdyna_operators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# contain information related to Units. In this case, as the simulation was run
2626
# through Mechanical, a file.actunits file is produced. If this file is
2727
# supplemented in the data_sources, the units will be correctly fetched for all
28-
# resuls in the file as well as for the mesh.
28+
# results in the file as well as for the mesh.
2929

3030
d3plot = examples.download_d3plot_beam()
3131
ds = dpf.DataSources()

ignore_words.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)