|
4 | 4 |
|
5 | 5 | """ |
6 | 6 |
|
7 | | -from collections import OrderedDict |
8 | 7 | import copy |
9 | 8 | import glob |
10 | 9 | import io |
11 | | -import numpy |
12 | 10 | import os |
13 | 11 | import re |
| 12 | +from collections import OrderedDict, UserDict |
| 13 | +from multiprocessing import Pipe, Process, RawArray |
14 | 14 |
|
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 |
16 | 31 |
|
17 | 32 | from boutdata.collect import ( |
18 | | - collect, |
19 | | - create_cache, |
20 | | - findVar, |
21 | 33 | _check_fieldperp_attributes, |
22 | 34 | _collect_from_one_proc, |
23 | 35 | _get_grid_info, |
| 36 | + collect, |
| 37 | + create_cache, |
| 38 | + findVar, |
24 | 39 | ) |
25 | 40 | from boututils.boutarray import BoutArray |
26 | 41 | from boututils.boutwarnings import alwayswarn |
27 | 42 | from boututils.datafile import DataFile |
28 | 43 | from boututils.run_wrapper import determineNumberOfCPUs |
29 | 44 |
|
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 | | - |
62 | 45 |
|
63 | 46 | class CaseInsensitiveDict(UserDict): |
64 | 47 | def __missing__(self, key): |
@@ -1345,11 +1328,12 @@ def redistribute(self, npes, nxpe=None, mxg=2, myg=2, include_restarts=True): |
1345 | 1328 | redistribute the restart files also (default: True) |
1346 | 1329 |
|
1347 | 1330 | """ |
| 1331 | + from os import mkdir, path, rename |
| 1332 | + |
1348 | 1333 | from boutdata.processor_rearrange import ( |
1349 | | - get_processor_layout, |
1350 | 1334 | create_processor_layout, |
| 1335 | + get_processor_layout, |
1351 | 1336 | ) |
1352 | | - from os import rename, path, mkdir |
1353 | 1337 |
|
1354 | 1338 | # use get_processor_layout to get nx, ny |
1355 | 1339 | old_processor_layout = get_processor_layout( |
@@ -1490,9 +1474,10 @@ def redistribute(self, npes, nxpe=None, mxg=2, myg=2, include_restarts=True): |
1490 | 1474 |
|
1491 | 1475 | if include_restarts: |
1492 | 1476 | print("processing restarts") |
1493 | | - from boutdata import restart |
1494 | 1477 | from glob import glob |
1495 | 1478 |
|
| 1479 | + from boutdata import restart |
| 1480 | + |
1496 | 1481 | restart_prefix = "BOUT.restart" |
1497 | 1482 | restarts_list = glob(path.join(self._path, restart_prefix + "*")) |
1498 | 1483 |
|
|
0 commit comments