Skip to content

Commit 19991c8

Browse files
committed
code formatting updates to match changes in black requirements
1 parent 991dc77 commit 19991c8

36 files changed

+100
-49
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ default_stages: [commit]
44

55
repos:
66
- repo: https://github.com/psf/black
7-
rev: 23.1.0
7+
rev: 24.1.1
88
hooks:
99
- id: black
1010

1111
- repo: https://github.com/timothycrosley/isort
12-
rev: 5.12.0
12+
rev: 5.13.2
1313
hooks:
1414
- id: isort
1515
args: ["--profile", "black"]
1616

1717
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: v4.4.0
18+
rev: v4.5.0
1919
hooks:
2020
- id: trailing-whitespace
2121
- id: end-of-file-fixer

PyMPDATA/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
`PyMPDATA.vector_field.VectorField` elements:
88
![](https://github.com/atmos-cloud-sim-uj/PyMPDATA/releases/download/tip/readme_grid.png)
99
"""
10+
1011
# pylint: disable=invalid-name
1112
from importlib.metadata import PackageNotFoundError, version
1213

PyMPDATA/boundary_conditions/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" classes representing boundary conditions """
2+
23
from .constant import Constant
34
from .extrapolated import Extrapolated
45
from .periodic import Periodic

PyMPDATA/boundary_conditions/constant.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" boundary condition filling halos with a constant value """
2+
23
# pylint: disable=too-many-arguments
34
from functools import lru_cache
45

PyMPDATA/boundary_conditions/extrapolated.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" boundary condition extrapolating values from the edge to the halo for scalars
22
and returning edge-of-the-domain value for vectors (with all negative scalar values
33
set to zero) """
4+
45
# pylint: disable=too-many-arguments
56
from functools import lru_cache
67

PyMPDATA/boundary_conditions/periodic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" periodic/cyclic boundary condition logic """
2+
23
from functools import lru_cache
34

45
import numba

PyMPDATA/boundary_conditions/polar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" polar boundary condition for use in with spherical coordinates """
2+
23
from functools import lru_cache
34

45
import numba

PyMPDATA/impl/clock.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" CPU-time returning clock() function which works from within njit-ted code,
22
no time unit guaranteed, returned value only for relative time measurements """
3+
34
import ctypes
45

56
clock = ctypes.pythonapi._PyTime_GetSystemClock # pylint:disable=protected-access

PyMPDATA/impl/domain_decomposition.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" logic defining domain decomposition scheme for multi-threading """
2+
23
import math
34

45
import numba

PyMPDATA/impl/enumerations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" common constants (mostly integer indices used for indexing tuples) """
2+
23
import numpy as np
34

45
ARG_FOCUS, ARG_DATA, ARG_DATA_OUTER, ARG_DATA_MID3D, ARG_DATA_INNER = 0, 1, 1, 2, 3

PyMPDATA/impl/field.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" common logic for `PyMPDATA.scalar_field.ScalarField` and
22
`PyMPDATA.vector_field.VectorField` classes """
3+
34
import abc
45
from collections import namedtuple
56

PyMPDATA/impl/formulae_antidiff.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" antidiffusive velocity formulae incl. divergent-flow,
22
third-order-terms, DPDC and partially also infinite-gauge logic """
3+
34
import numba
45
import numpy as np
56

@@ -12,16 +13,18 @@ def make_antidiff(non_unit_g_factor, options, traversals, last_pass=False):
1213
apply_vector = traversals.apply_vector()
1314

1415
formulae_antidiff = tuple(
15-
__make_antidiff(
16-
atv=idx.atv[i],
17-
ats=idx.ats[i],
18-
non_unit_g_factor=non_unit_g_factor,
19-
options=options,
20-
n_dims=traversals.n_dims,
21-
last_pass=last_pass,
16+
(
17+
__make_antidiff(
18+
atv=idx.atv[i],
19+
ats=idx.ats[i],
20+
non_unit_g_factor=non_unit_g_factor,
21+
options=options,
22+
n_dims=traversals.n_dims,
23+
last_pass=last_pass,
24+
)
25+
if idx.ats[i] is not None
26+
else None
2227
)
23-
if idx.ats[i] is not None
24-
else None
2528
for i in range(MAX_DIM_NUM)
2629
)
2730

PyMPDATA/impl/formulae_axpy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" basic a*x+y operation logic for use in Fickian term handling """
2+
23
import numba
34

45
from .enumerations import INNER, MID3D, OUTER

PyMPDATA/impl/formulae_flux.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" staggered-grid flux logic including infinite-gauge logic handling """
2+
23
import numba
34
import numpy as np
45

@@ -11,15 +12,17 @@ def make_flux_first_pass(options, traversals):
1112
apply_vector = traversals.apply_vector()
1213

1314
formulae_flux_first_pass = tuple(
14-
__make_flux(
15-
options.jit_flags,
16-
idx.atv[i],
17-
idx.ats[i],
18-
first_pass=True,
19-
infinite_gauge=False,
15+
(
16+
__make_flux(
17+
options.jit_flags,
18+
idx.atv[i],
19+
idx.ats[i],
20+
first_pass=True,
21+
infinite_gauge=False,
22+
)
23+
if idx.ats[i] is not None
24+
else None
2025
)
21-
if idx.ats[i] is not None
22-
else None
2326
for i in range(MAX_DIM_NUM)
2427
)
2528

@@ -47,15 +50,17 @@ def make_flux_subsequent(options, traversals):
4750
apply_vector = traversals.apply_vector()
4851

4952
formulae_flux_subsequent = tuple(
50-
__make_flux(
51-
options.jit_flags,
52-
idx.atv[i],
53-
idx.ats[i],
54-
first_pass=False,
55-
infinite_gauge=options.infinite_gauge,
53+
(
54+
__make_flux(
55+
options.jit_flags,
56+
idx.atv[i],
57+
idx.ats[i],
58+
first_pass=False,
59+
infinite_gauge=options.infinite_gauge,
60+
)
61+
if idx.ats[i] is not None
62+
else None
5663
)
57-
if idx.ats[i] is not None
58-
else None
5964
for i in range(MAX_DIM_NUM)
6065
)
6166

PyMPDATA/impl/formulae_laplacian.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" logic for handling the Fickian term by modifying physical velocity """
2+
23
import numba
34

45
from ..impl.enumerations import MAX_DIM_NUM
@@ -19,11 +20,13 @@ def apply(_1, _2, _3):
1920
apply_vector = traversals.apply_vector()
2021

2122
formulae_laplacian = tuple(
22-
__make_laplacian(
23-
options.jit_flags, idx.ats[i], options.epsilon, non_unit_g_factor
23+
(
24+
__make_laplacian(
25+
options.jit_flags, idx.ats[i], options.epsilon, non_unit_g_factor
26+
)
27+
if idx.ats[i] is not None
28+
else None
2429
)
25-
if idx.ats[i] is not None
26-
else None
2730
for i in range(MAX_DIM_NUM)
2831
)
2932

PyMPDATA/impl/formulae_nonoscillatory.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,11 @@ def apply(_, __, ___):
288288
apply_vector = traversals.apply_vector()
289289

290290
formulae = tuple(
291-
__make_correction(options.jit_flags, idx.ats[i], idx.atv[i])
292-
if idx.ats[i] is not None
293-
else None
291+
(
292+
__make_correction(options.jit_flags, idx.ats[i], idx.atv[i])
293+
if idx.ats[i] is not None
294+
else None
295+
)
294296
for i in range(MAX_DIM_NUM)
295297
)
296298

PyMPDATA/impl/formulae_upwind.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" upwind/donor-cell formula logic including G-factor handling """
2+
23
import numba
34

45
from PyMPDATA.impl.enumerations import MAX_DIM_NUM
@@ -10,9 +11,11 @@ def make_upwind(options, non_unit_g_factor, traversals):
1011
idx = traversals.indexers[traversals.n_dims]
1112

1213
formulae_upwind = tuple(
13-
__make_upwind(options.jit_flags, idx.atv[i], idx.ats[i], non_unit_g_factor)
14-
if idx.ats[i] is not None
15-
else None
14+
(
15+
__make_upwind(options.jit_flags, idx.atv[i], idx.ats[i], non_unit_g_factor)
16+
if idx.ats[i] is not None
17+
else None
18+
)
1619
for i in range(MAX_DIM_NUM)
1720
)
1821

PyMPDATA/impl/grid.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
static (extents known to JIT) and dynamic (run-time extents) grid handling logic
33
"""
4+
45
import numba
56

67
from PyMPDATA.impl.domain_decomposition import make_subdomain

PyMPDATA/impl/indexers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" array indexing logic for 1D, 2D and 3D staggered grids """
2+
23
# pylint: disable=missing-function-docstring
34

45
from collections import namedtuple

PyMPDATA/impl/meta.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" constants for indexing and a factory for creating the "meta" tuples """
2+
23
from collections import namedtuple
34
from pathlib import Path
45

PyMPDATA/impl/traversals.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" staggered-grid traversals orchestration """
2+
23
from collections import namedtuple
34
from pathlib import Path
45

PyMPDATA/impl/traversals_common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" commons for scalar and vector field traversals """
2+
23
# pylint: disable=too-many-arguments,line-too-long,unused-argument
34
import numba
45

PyMPDATA/impl/traversals_halos_scalar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" halo-filling logic for scalar field traversals (incl. multi-threading) """
2+
23
# pylint: disable=too-many-arguments
34
import numba
45

PyMPDATA/impl/traversals_halos_vector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" halo-filling logic for vector field traversals (incl. multi-threading) """
2+
23
# pylint: disable=too-many-statements,too-many-locals,too-many-lines,too-many-function-args,too-many-arguments
34

45
import numba

PyMPDATA/impl/traversals_scalar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" scalar field traversals (incl. multi-threading) """
2+
23
import numba
34

45
from .enumerations import INNER, INVALID_INDEX, MID3D, RNG_START, RNG_STOP

PyMPDATA/impl/traversals_vector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" vector field traversals (incl. multi-threading) """
2+
23
import numba
34

45
from .enumerations import (

PyMPDATA/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
MPDATA variants, iterations, data-type and jit-flags settings
33
"""
4+
45
import numpy as np
56
from pystrict import strict
67

PyMPDATA/scalar_field.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
scalar field abstractions for the staggered grid
33
"""
4+
45
import inspect
56

67
import numpy as np

PyMPDATA/solver.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
class grouping user-supplied stepper, fields and post-step/post-iter hooks,
33
as well as self-initialised temporary storage
44
"""
5+
56
from typing import Union
67

78
import numba
@@ -71,15 +72,21 @@ def null_vector_field():
7172
"g_factor": g_factor or null_scalar_field(),
7273
"vectmp_a": vector_field(),
7374
"vectmp_b": vector_field(),
74-
"vectmp_c": vector_field()
75-
if stepper.options.non_zero_mu_coeff
76-
else null_vector_field(),
77-
"nonosc_xtrm": scalar_field(dtype=complex)
78-
if stepper.options.nonoscillatory
79-
else null_scalar_field(),
80-
"nonosc_beta": scalar_field(dtype=complex)
81-
if stepper.options.nonoscillatory
82-
else null_scalar_field(),
75+
"vectmp_c": (
76+
vector_field()
77+
if stepper.options.non_zero_mu_coeff
78+
else null_vector_field()
79+
),
80+
"nonosc_xtrm": (
81+
scalar_field(dtype=complex)
82+
if stepper.options.nonoscillatory
83+
else null_scalar_field()
84+
),
85+
"nonosc_beta": (
86+
scalar_field(dtype=complex)
87+
if stepper.options.nonoscillatory
88+
else null_scalar_field()
89+
),
8390
}
8491
for field in self.__fields.values():
8592
field.assemble(stepper.traversals)

PyMPDATA/stepper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" MPDATA iteration logic """
2+
23
import sys
34
import warnings
45
from functools import lru_cache

PyMPDATA/vector_field.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
vector field abstractions for the staggered grid
33
"""
4+
45
import inspect
56

67
import numpy as np

examples/PyMPDATA_examples/Shipway_and_Hill_2012/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def drhod_dz(z, rhod):
6969
self.rhod = interp1d(z_points, rhod_solution.y[0])
7070

7171
self.t_1 = 600 * si.s
72-
self.rhod_w = (
73-
lambda t: rhod_w_const * np.sin(np.pi * t / self.t_1) if t < self.t_1 else 0
72+
self.rhod_w = lambda t: (
73+
rhod_w_const * np.sin(np.pi * t / self.t_1) if t < self.t_1 else 0
7474
)
7575

7676
self.r_min = r_min

examples/PyMPDATA_examples/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
PyMPDATA_examples package includes common Python modules used in PyMPDATA smoke tests
33
and in example notebooks (but the package wheels do not include the notebooks)
44
"""
5+
56
from importlib.metadata import PackageNotFoundError, version
67

78
try:

examples/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" the magick behind ``pip install ...`` """
2+
23
import os
34

45
from setuptools import find_packages, setup

0 commit comments

Comments
 (0)