Skip to content

Commit 7992f64

Browse files
authored
Merge pull request #106 from boutproject/fix-format-ci
Fix formatting CI
2 parents f9ed3d1 + d4c009c commit 7992f64

21 files changed

Lines changed: 84 additions & 136 deletions

.github/workflows/black-fix.yml

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

.github/workflows/formatting.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Formatting (black & isort)
22
on:
33
push:
4-
branches: master
54
paths:
65
- '**.py'
76

@@ -27,12 +26,12 @@ jobs:
2726
python --version
2827
black --version
2928
isort --version
30-
- name: Run black
31-
run: |
32-
black boututils
3329
- name: Run isort
3430
run: |
35-
isort boututils
31+
isort src
32+
- name: Run black
33+
run: |
34+
black src
3635
- uses: stefanzweifel/git-auto-commit-action@v4
3736
with:
3837
commit_message: "[skip ci] Apply black/isort changes"

src/boutdata/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
""" Routines for exchanging data to/from BOUT++ """
22

3-
from boutdata.collect import collect, attributes
3+
from boutdata.collect import attributes, collect
44
from boututils.boutarray import BoutArray
55
from boututils.boutwarnings import alwayswarn
66
from boututils.run_wrapper import (
7+
build_and_log,
8+
determineNumberOfCPUs,
79
launch,
810
launch_safe,
911
shell,
1012
shell_safe,
11-
determineNumberOfCPUs,
12-
build_and_log,
1313
)
1414

15-
1615
__all__ = [
1716
"attributes",
1817
"collect",
@@ -31,18 +30,19 @@
3130
__name__ = "boutdata"
3231

3332
try:
34-
from importlib.metadata import version, PackageNotFoundError
33+
from importlib.metadata import PackageNotFoundError, version
3534
except ModuleNotFoundError:
36-
from importlib_metadata import version, PackageNotFoundError
35+
from importlib_metadata import PackageNotFoundError, version
3736
try:
3837
# This gives the version if the boutdata package was installed
3938
__version__ = version(__name__)
4039
except PackageNotFoundError:
4140
# This branch handles the case when boutdata is used from the git repo
4241
try:
43-
from setuptools_scm import get_version
4442
from pathlib import Path
4543

44+
from setuptools_scm import get_version
45+
4646
path = Path(__file__).resolve()
4747
__version__ = get_version(root="..", relative_to=path)
4848
except (ModuleNotFoundError, LookupError):

src/boutdata/collect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import glob
12
import os
23
import sys
3-
import glob
44

55
import numpy as np
66

7-
from boututils.datafile import DataFile
87
from boututils.boutarray import BoutArray
8+
from boututils.datafile import DataFile
99

1010

1111
def findVar(varname, varlist):

src/boutdata/data.py

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,44 @@
44
55
"""
66

7-
from collections import OrderedDict
87
import copy
98
import glob
109
import io
11-
import numpy
1210
import os
1311
import re
12+
from collections import OrderedDict, UserDict
13+
from multiprocessing import Pipe, Process, RawArray
1414

15-
from multiprocessing import Process, Pipe, RawArray
15+
import numpy
16+
17+
# These are imported to be used by 'eval' in
18+
# BoutOptions.evaluate_scalar() and BoutOptionsFile.evaluate().
19+
# Change the names to match those used by C++/BOUT++
20+
from numpy import abs as abs # noqa: F401
21+
from numpy import arccos as acos # noqa: F401
22+
from numpy import arccosh as acosh # noqa: F401
23+
from numpy import arcsin as asin # noqa: F401
24+
from numpy import arcsinh as asinh # noqa: F401
25+
from numpy import arctan as atan # noqa: F401
26+
from numpy import arctan2 as atan2 # noqa: F401
27+
from numpy import arctanh as atanh # noqa: F401
28+
from numpy import ceil, cos, cosh, exp, floor, log, log10, pi # noqa: F401
29+
from numpy import power as pow # noqa: F401
30+
from numpy import round, sin, sinh, sqrt, tan, tanh # noqa: F401
1631

1732
from boutdata.collect import (
18-
collect,
19-
create_cache,
20-
findVar,
2133
_check_fieldperp_attributes,
2234
_collect_from_one_proc,
2335
_get_grid_info,
36+
collect,
37+
create_cache,
38+
findVar,
2439
)
2540
from boututils.boutarray import BoutArray
2641
from boututils.boutwarnings import alwayswarn
2742
from boututils.datafile import DataFile
2843
from boututils.run_wrapper import determineNumberOfCPUs
2944

30-
# These are imported to be used by 'eval' in
31-
# BoutOptions.evaluate_scalar() and BoutOptionsFile.evaluate().
32-
# Change the names to match those used by C++/BOUT++
33-
from numpy import ( # noqa: F401
34-
pi,
35-
sin,
36-
cos,
37-
tan,
38-
arccos as acos,
39-
arcsin as asin,
40-
arctan as atan,
41-
arctan2 as atan2,
42-
sinh,
43-
cosh,
44-
tanh,
45-
arcsinh as asinh,
46-
arccosh as acosh,
47-
arctanh as atanh,
48-
exp,
49-
log,
50-
log10,
51-
power as pow,
52-
sqrt,
53-
ceil,
54-
floor,
55-
round,
56-
abs,
57-
)
58-
59-
60-
from collections import UserDict
61-
6245

6346
class CaseInsensitiveDict(UserDict):
6447
def __missing__(self, key):
@@ -1345,11 +1328,12 @@ def redistribute(self, npes, nxpe=None, mxg=2, myg=2, include_restarts=True):
13451328
redistribute the restart files also (default: True)
13461329
13471330
"""
1331+
from os import mkdir, path, rename
1332+
13481333
from boutdata.processor_rearrange import (
1349-
get_processor_layout,
13501334
create_processor_layout,
1335+
get_processor_layout,
13511336
)
1352-
from os import rename, path, mkdir
13531337

13541338
# use get_processor_layout to get nx, ny
13551339
old_processor_layout = get_processor_layout(
@@ -1490,9 +1474,10 @@ def redistribute(self, npes, nxpe=None, mxg=2, myg=2, include_restarts=True):
14901474

14911475
if include_restarts:
14921476
print("processing restarts")
1493-
from boutdata import restart
14941477
from glob import glob
14951478

1479+
from boutdata import restart
1480+
14961481
restart_prefix = "BOUT.restart"
14971482
restarts_list = glob(path.join(self._path, restart_prefix + "*"))
14981483

src/boutdata/griddata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
33
"""
44

5-
from numpy import ndarray, zeros, concatenate, linspace, amin, amax
6-
import numpy as np
75
import matplotlib.pyplot as plt
6+
import numpy as np
7+
from numpy import amax, amin, concatenate, linspace, ndarray, zeros
88

99
from boututils.datafile import DataFile
1010

src/boutdata/input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
"""
44

5-
from numpy.fft import rfft
65
from numpy import ndarray
6+
from numpy.fft import rfft
77

88

99
def transform3D(arr):

src/boutdata/mayavi2.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import numpy as np
2-
from numpy import cos, sin, pi
3-
4-
from enthought.tvtk.api import tvtk
52
from enthought.mayavi.scripts import mayavi2
3+
from enthought.tvtk.api import tvtk
4+
from numpy import cos, pi, sin
65

76

87
def aligned_points(grid, nz=1, period=1.0, maxshift=0.4):
@@ -74,8 +73,8 @@ def create_grid(grid, data, period=1):
7473

7574
@mayavi2.standalone
7675
def view3d(sgrid):
76+
from enthought.mayavi.modules.api import GridPlane, Outline
7777
from enthought.mayavi.sources.vtk_data_source import VTKDataSource
78-
from enthought.mayavi.modules.api import Outline, GridPlane
7978

8079
mayavi2.new_scene()
8180
src = VTKDataSource(data=sgrid)

src/boutdata/mms.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
44
"""
55

6-
from sympy import symbols, cos, sin, diff, sqrt, pi, simplify, trigsimp, integrate, Wild
7-
86
from numpy import arange, zeros
7+
from sympy import Wild, cos, diff, integrate, pi, simplify, sin, sqrt, symbols, trigsimp
98

109
# Constants
1110
qe = 1.602e-19

src/boutdata/pol_slice.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from boututils.datafile import DataFile
21
import numpy as np
32
from scipy.ndimage import map_coordinates
43

4+
from boututils.datafile import DataFile
5+
56

67
def pol_slice(var3d, gridfile, n=1, zangle=0.0, nyInterp=None):
78
"""Takes a 3D variable, and returns a 2D slice at fixed toroidal angle

0 commit comments

Comments
 (0)