Skip to content

Commit 3853f9c

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 0f90c55 commit 3853f9c

19 files changed

Lines changed: 427 additions & 146 deletions

docs/source/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@
186186

187187
# One entry per manual page. List of tuples
188188
# (source start file, name, description, authors, manual section).
189-
man_pages = [(master_doc, "openPMD-api", "openPMD-api Documentation", [author], 1)]
189+
man_pages = [
190+
(master_doc, "openPMD-api", "openPMD-api Documentation", [author], 1)
191+
]
190192

191193

192194
# -- Options for Texinfo output -------------------------------------------

examples/10_streaming_read.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
# pass-through for ADIOS2 engine parameters
77
# https://adios2.readthedocs.io/en/latest/engines/engines.html
88
config = {"adios2": {"engine": {}, "dataset": {}}}
9-
config["adios2"]["engine"] = {"parameters": {"Threads": "4", "DataTransport": "WAN"}}
9+
config["adios2"]["engine"] = {
10+
"parameters": {"Threads": "4", "DataTransport": "WAN"}
11+
}
1012
config["adios2"]["dataset"] = {"operators": [{"type": "bzip2"}]}
1113

1214
if __name__ == "__main__":

examples/10_streaming_write.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
# pass-through for ADIOS2 engine parameters
88
# https://adios2.readthedocs.io/en/latest/engines/engines.html
99
config = {"adios2": {"engine": {}, "dataset": {}}}
10-
config["adios2"]["engine"] = {"parameters": {"Threads": "4", "DataTransport": "WAN"}}
10+
config["adios2"]["engine"] = {
11+
"parameters": {"Threads": "4", "DataTransport": "WAN"}
12+
}
1113
config["adios2"]["dataset"] = {"operators": [{"type": "bzip2"}]}
1214

1315
if __name__ == "__main__":
@@ -40,7 +42,9 @@
4042
electronPositions.set_attribute("comment", "I'm a comment")
4143

4244
length = 10
43-
local_data = np.arange(i * length, (i + 1) * length, dtype=np.dtype("double"))
45+
local_data = np.arange(
46+
i * length, (i + 1) * length, dtype=np.dtype("double")
47+
)
4448
for dim in ["x", "y", "z"]:
4549
pos = electronPositions[dim]
4650
pos.reset_dataset(io.Dataset(local_data.dtype, [length]))
@@ -60,7 +64,9 @@
6064
# temperature has no x,y,z components, so skip the last layer:
6165
temperature_dataset = temperature
6266
# let's say we are in a 3x3 mesh
63-
temperature_dataset.reset_dataset(io.Dataset(np.dtype("double"), [3, 3]))
67+
temperature_dataset.reset_dataset(
68+
io.Dataset(np.dtype("double"), [3, 3])
69+
)
6470
# temperature is constant
6571
temperature_dataset.make_constant(273.15)
6672

examples/11_particle_dataframe.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@
121121
Intensity_max = Intensity.max().compute()
122122
idx_max = da.argwhere(Intensity == Intensity_max).compute()[0]
123123
pos_max = (
124-
E.grid_unit_SI * 1.0e6 * (idx_max * E.grid_spacing + E.grid_global_offset)
124+
E.grid_unit_SI
125+
* 1.0e6
126+
* (idx_max * E.grid_spacing + E.grid_global_offset)
125127
)
126128
print(
127129
"maximum intensity I={} at index={} z={}mu".format(

examples/13_write_dynamic_configuration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ def main():
8282
electronPositions.set_attribute("comment", "I'm a comment")
8383

8484
length = 10
85-
local_data = np.arange(i * length, (i + 1) * length, dtype=np.dtype("double"))
85+
local_data = np.arange(
86+
i * length, (i + 1) * length, dtype=np.dtype("double")
87+
)
8688
for dim in ["x", "y", "z"]:
8789
pos = electronPositions[dim]
8890
pos.reset_dataset(io.Dataset(local_data.dtype, [length]))

examples/15_compression.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def write(filename, config):
6262

6363
position = e["position"][dim]
6464
position.reset_dataset(opmd.Dataset(np.dtype("float"), [100]))
65-
position[:] = np.arange(i * 100, (i + 1) * 100, dtype=np.dtype("float"))
65+
position[:] = np.arange(
66+
i * 100, (i + 1) * 100, dtype=np.dtype("float")
67+
)
6668

6769

6870
def main():

examples/2_read_serial.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
)
1818
print("Read a Series with openPMD standard version %s" % series.openPMD)
1919

20-
print("The Series contains {0} iterations:".format(len(series.snapshots())))
20+
print(
21+
"The Series contains {0} iterations:".format(len(series.snapshots()))
22+
)
2123
for i in series.snapshots():
2224
print("\t {0}".format(i))
2325
print("")
@@ -28,7 +30,9 @@
2830
for m in i.meshes:
2931
print("\t {0}".format(m))
3032
print("")
31-
print("Iteration 100 contains {0} particle species:".format(len(i.particles)))
33+
print(
34+
"Iteration 100 contains {0} particle species:".format(len(i.particles))
35+
)
3236
for ps in i.particles:
3337
print("\t {0}".format(ps))
3438
print("With records:")

examples/3_write_serial.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@
1717
# matrix dataset to write with values 0...size*size-1
1818
data = np.arange(size * size, dtype=np.double).reshape(3, 3)
1919

20-
print("Set up a 2D square array ({0}x{1}) that will be written".format(size, size))
20+
print(
21+
"Set up a 2D square array ({0}x{1}) that will be written".format(
22+
size, size
23+
)
24+
)
2125

2226
# open file for writing
23-
series = io.Series("../samples/3_write_serial_py.h5", io.Access.create_linear)
27+
series = io.Series(
28+
"../samples/3_write_serial_py.h5", io.Access.create_linear
29+
)
2430

2531
print("Created an empty {0} Series".format(series.iteration_encoding))
2632

examples/5_write_parallel.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import adios2
2020
from packaging import version
2121

22-
USE_JOINED_DIMENSION = version.parse(adios2.__version__) >= version.parse("2.9.0")
22+
USE_JOINED_DIMENSION = version.parse(adios2.__version__) >= version.parse(
23+
"2.9.0"
24+
)
2325
except ImportError:
2426
USE_JOINED_DIMENSION = False
2527

@@ -30,7 +32,9 @@
3032
# global data set to write: [MPI_Size * 10, 300]
3133
# each rank writes a 10x300 slice with its MPI rank as values
3234
local_value = comm.rank
33-
local_data = np.ones(10 * 300, dtype=np.double).reshape(10, 300) * local_value
35+
local_data = (
36+
np.ones(10 * 300, dtype=np.double).reshape(10, 300) * local_value
37+
)
3438
if 0 == comm.rank:
3539
print(
3640
"Set up a 2D array with 10x300 elements per MPI rank ({}x) "
@@ -46,7 +50,11 @@
4650
comm,
4751
)
4852
if 0 == comm.rank:
49-
print("Created an empty series in parallel with {} MPI ranks".format(comm.size))
53+
print(
54+
"Created an empty series in parallel with {} MPI ranks".format(
55+
comm.size
56+
)
57+
)
5058

5159
# In parallel contexts, it's important to explicitly open iterations.
5260
# However, we use Access mode CREATE_LINEAR, so the Series creates

examples/7_extended_write_serial.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
"""
99

1010
import numpy as np
11-
from openpmd_api import Access, Dataset, Mesh_Record_Component, Series, Unit_Dimension
11+
from openpmd_api import (
12+
Access,
13+
Dataset,
14+
Mesh_Record_Component,
15+
Series,
16+
Unit_Dimension,
17+
)
1218

1319
SCALAR = Mesh_Record_Component.SCALAR
1420

@@ -54,9 +60,7 @@
5460
# alternatively, a copy may be created and later re-assigned to
5561
# f.snapshots()[1]
5662
copy = f.snapshots()[1] # TODO .copy()
57-
copy.comment = (
58-
"Modifications to copies will only take effect after you reassign the copy"
59-
)
63+
copy.comment = "Modifications to copies will only take effect after you reassign the copy"
6064
f.snapshots()[1] = copy
6165
del copy
6266

@@ -84,7 +88,8 @@
8488
# particles are handled very similar
8589
electrons = cur_it.particles["electrons"]
8690
electrons.set_attribute(
87-
"NoteWorthyParticleSpeciesProperty", "Observing this species was a blast."
91+
"NoteWorthyParticleSpeciesProperty",
92+
"Observing this species was a blast.",
8893
)
8994
electrons["displacement"].unit_dimension = {Unit_Dimension.M: 1}
9095
electrons["displacement"]["x"].unit_SI = 1.0e-6
@@ -105,7 +110,9 @@
105110
# written to disk
106111
dataset_config = {
107112
"adios2": {
108-
"dataset": {"operators": [{"type": "zlib", "parameters": {"clevel": 9}}]}
113+
"dataset": {
114+
"operators": [{"type": "zlib", "parameters": {"clevel": 9}}]
115+
}
109116
}
110117
}
111118
d = Dataset(partial_mesh.dtype, extent=[2, 5], options=dataset_config)
@@ -173,7 +180,10 @@
173180
)
174181

175182
electrons.particle_patches["offset"]["x"].store(
176-
i, np.array([particle_position[numParticlesOffset]], dtype=np.float32)
183+
i,
184+
np.array(
185+
[particle_position[numParticlesOffset]], dtype=np.float32
186+
),
177187
)
178188
electrons.particle_patches["extent"]["x"].store(
179189
i,

0 commit comments

Comments
 (0)