Skip to content

Commit 198cbb3

Browse files
authored
Clean Tests & Includes (#211)
Issues seen with `pyflakes` and `ruff`.
1 parent 00d21ef commit 198cbb3

21 files changed

+35
-51
lines changed

src/amrex/ArrayOfStructs.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
Authors: Axel Huebl
66
License: BSD-3-Clause-LBNL
77
"""
8-
from collections import namedtuple
98

109

1110
def aos_to_numpy(self, copy=False):
@@ -65,10 +64,6 @@ def aos_to_cupy(self, copy=False):
6564
"""
6665
import cupy as cp
6766

68-
SoA_cp = namedtuple(type(self).__name__ + "_cp", ["real", "int"])
69-
70-
soa_view = SoA_cp([], [])
71-
7267
if self.size() == 0:
7368
raise ValueError("AoS is empty.")
7469

src/amrex/StructOfArrays.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ def soa_to_numpy(self, copy=False):
2525
A tuple with real and int components that are each lists
2626
of 1D numpy arrays.
2727
"""
28-
import numpy as np
29-
3028
SoA_np = namedtuple(type(self).__name__ + "_np", ["real", "int"])
3129

3230
soa_view = SoA_np([], [])
@@ -65,8 +63,6 @@ def soa_to_cupy(self, copy=False):
6563
ImportError
6664
Raises an exception if cupy is not installed
6765
"""
68-
import cupy as cp
69-
7066
SoA_cp = namedtuple(type(self).__name__ + "_cp", ["real", "int"])
7167

7268
soa_view = SoA_cp([], [])

src/amrex/space1d/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def d_decl(x, y, z):
3737

3838
def Print(*args, **kwargs):
3939
"""Wrap amrex::Print() - only the IO processor writes"""
40-
if not initialized():
40+
if not initialized(): # noqa
4141
print("warning: Print all - AMReX not initialized")
4242
print(*args, **kwargs)
43-
elif ParallelDescriptor.IOProcessor():
43+
elif ParallelDescriptor.IOProcessor(): # noqa
4444
print(*args, **kwargs)
4545

4646

src/amrex/space2d/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def d_decl(x, y, z):
3737

3838
def Print(*args, **kwargs):
3939
"""Wrap amrex::Print() - only the IO processor writes"""
40-
if not initialized():
40+
if not initialized(): # noqa
4141
print("warning: Print all - AMReX not initialized")
4242
print(*args, **kwargs)
43-
elif ParallelDescriptor.IOProcessor():
43+
elif ParallelDescriptor.IOProcessor(): # noqa
4444
print(*args, **kwargs)
4545

4646

src/amrex/space3d/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def d_decl(x, y, z):
3737

3838
def Print(*args, **kwargs):
3939
"""Wrap amrex::Print() - only the IO processor writes"""
40-
if not initialized():
40+
if not initialized(): # noqa
4141
print("warning: Print all - AMReX not initialized")
4242
print(*args, **kwargs)
43-
elif ParallelDescriptor.IOProcessor():
43+
elif ParallelDescriptor.IOProcessor(): # noqa
4444
print(*args, **kwargs)
4545

4646

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
except ImportError:
1717
raise ImportError("AMReX: No 1D, 2D or 3D module found!")
1818

19+
# Import calls MPI_Initialize, if not called already
1920
if amr.Config.have_mpi:
20-
from mpi4py import MPI
21+
from mpi4py import MPI # noqa
2122

2223
# base path for input files
2324
basepath = os.getcwd()

tests/test_aos.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22

33
import numpy as np
4-
import pytest
54

65
import amrex.space3d as amr
76

@@ -85,6 +84,9 @@ def test_array_interface():
8584
print(arr)
8685
print(aos[0], aos[1])
8786
print("-------")
87+
aos[0] = p4
88+
assert aos[0].x == 0
89+
assert aos[0].y == -5
8890
aos[0] = p3
8991
print("array:", arr)
9092
print("aos[0]:", aos[0], "aos[1]:", aos[1])

tests/test_array4.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ def test_array4_numba():
8787
) # type: numpy.ndarray
8888

8989
# host-to-device copy
90-
x_numba = cuda.to_device(x) # type: numba.cuda.cudadrv.devicearray.DeviceNDArray
91-
# x_cupy = cupy.asarray(x_numba) # type: cupy.ndarray
90+
x_numba = cuda.to_device(x) # noqa
91+
# type is numba.cuda.cudadrv.devicearray.DeviceNDArray
92+
# x_cupy = cupy.asarray(x_numba)
93+
# type is cupy.ndarray
9294

9395
# TODO: Implement __cuda_array_interface__ or DLPack in Array4 constructor
9496
# x_arr = amr.Array4_double(x_numba) # type: amr.Array4_double

tests/test_basefab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
def test_basefab():
9-
bf = amr.BaseFab_Real()
9+
bf = amr.BaseFab_Real() # noqa
1010

1111

1212
def test_basefab_to_host():

tests/test_coordsys.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
import numpy as np
4-
import pytest
5-
63
import amrex.space3d as amr
74

85
# import amrex.space3d as amr.CoordSys.CoordType as CoordType

0 commit comments

Comments
 (0)