Skip to content

Commit 07ef55e

Browse files
committed
Fixing some minor codacy issues
1 parent 6522e43 commit 07ef55e

11 files changed

+18
-16
lines changed

.pylintrc

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ disable = locally-disabled,
77
redefined-builtin,
88
unused-argument,
99
too-many-arguments,
10+
too-many-return-statements,
1011
line-too-long,
1112
no-member,
1213
not-callable,

mpi4py_fft/distarray.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def redistribute(self, axis=None, out=None):
323323
# axis of pencil (both axes are undivided) and return
324324
if axis is not None:
325325
if self.commsizes[self.rank+axis] == 1:
326-
self._p0.axis = axis
326+
self.pencil.axis = axis
327327
return self
328328

329329
if out is not None:
@@ -337,9 +337,9 @@ def redistribute(self, axis=None, out=None):
337337

338338
# Check that arrays are compatible
339339
for i in range(len(self._p0.shape)):
340-
if i != self._p0.axis and i != out._p0.axis:
341-
assert self._p0.subcomm[i] == out._p0.subcomm[i]
342-
assert self._p0.subshape[i] == out._p0.subshape[i]
340+
if i not in (self.alignment, out.alignment):
341+
assert self.pencil.subcomm[i] == out.pencil.subcomm[i]
342+
assert self.pencil.subshape[i] == out.pencil.subshape[i]
343343

344344
p1, transfer = self.get_pencil_and_transfer(axis)
345345
if out is None:

mpi4py_fft/fftw/factory.py

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def get_fftw_lib(dtype):
3838
return fftwf_xfftn
3939
except ImportError: #pragma: no cover
4040
return None
41+
else: #pragma: no cover
42+
return None
4143

4244
fftlib = {}
4345
for t in 'fdg':

mpi4py_fft/fftw/fftw_planxfftn.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fftw_plan fftw_planxfftn(int ndims,
1818
unsigned flags)
1919
{
2020
fftw_iodim ranks[ndims], dims[ndims];
21-
int i, j, axis;
21+
int i, j;
2222
int strides_in[ndims], strides_out[ndims], markers[ndims];
2323
int *sizes = (kind[0] != C2R) ? sizes_in : sizes_out;
2424

@@ -32,7 +32,7 @@ fftw_plan fftw_planxfftn(int ndims,
3232
for (i = 0; i < ndims; i++)
3333
markers[i] = 0;
3434
for (i = 0; i < naxes; i++) {
35-
axis = axes[i];
35+
int axis = axes[i];
3636
ranks[i].n = sizes[axis];
3737
ranks[i].is = strides_in[axis];
3838
ranks[i].os = strides_out[axis];
@@ -75,4 +75,3 @@ fftw_plan fftw_planxfftn(int ndims,
7575
flags);
7676
}
7777
}
78-

mpi4py_fft/io/h5py_file.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ def _check_domain(self, group, field):
3939
assert len(self.domain) == field.dimensions
4040
self.f.require_group(group)
4141
if not "shape" in self.f[group].attrs:
42-
self.f[group].attrs.create("shape", field._p0.shape)
42+
self.f[group].attrs.create("shape", field.pencil.shape)
4343
if not "rank" in self.f[group].attrs:
4444
self.f[group].attrs.create("rank", field.rank)
4545
assert field.rank == self.f[group].attrs["rank"]
46-
assert np.all(field._p0.shape == self.f[group].attrs["shape"])
46+
assert np.all(field.pencil.shape == self.f[group].attrs["shape"])
4747
if isinstance(self.domain[0], np.ndarray):
4848
self.f[group].require_group("mesh")
4949
else:

mpi4py_fft/libfft.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ def __init__(self, shape, axes=None, dtype=float, padding=False,
387387
self.fwd, self.bck = plan(self.shape, self.axes, self.dtype, transforms, kw)
388388
U, V = self.fwd.input_array, self.fwd.output_array
389389
self.M = 1
390-
if not backend == 'fftw':
390+
if backend != 'fftw':
391391
self.M = 1./np.prod(np.take(self.shape, self.axes))
392-
elif backend == 'fftw':
392+
else:
393393
self.M = self.fwd.get_normalization()
394394
if backend == 'scipy':
395395
self.real_transform = False # No rfftn/irfftn methods

mpi4py_fft/mpifft.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def __init__(self, comm, shape=None, axes=None, dtype=float, grid=None,
208208

209209
if shape is None:
210210
assert darray is not None
211-
shape = darray._p0.shape
211+
shape = darray.pencil.shape
212212

213213
if axes is not None:
214214
axes = list(axes) if np.ndim(axes) else [axes]

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,4 @@ def version():
215215
install_requires=["mpi4py", "numpy"],
216216
setup_requires=["setuptools>=18.0", "cython>=0.25"],
217217
keywords=['Python', 'FFTW', 'FFT', 'DCT', 'DST', 'MPI']
218-
)
218+
)

tests/test_darray.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_2Darray():
5757

5858
def test_3Darray():
5959
N = (8, 8, 8)
60-
for subcomm in ((0, 0, 1), (0, 1, 0), (1, 0, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0), None, Subcomm(comm, (0, 0, 1))):
60+
for subcomm in ((0, 0, 1), (0, 1, 0), (1, 0, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0), None, Subcomm(comm, (0, 0, 1))):
6161
for rank in (0, 1, 2):
6262
M = (3,)*rank + N
6363
alignment = None

tests/test_fftw.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_fftw():
9696
# r2r
9797
input_array = fftw.aligned(shape, dtype=typecode)
9898
output_array = fftw.aligned_like(input_array)
99-
oa = output_array if typecode=='d' else None
99+
oa = output_array if typecode =='d' else None
100100
for type in (1, 2, 3, 4):
101101
dct = fftw.dctn(input_array, None, axes, type, threads, fflags, output_array=oa)
102102
B = dct(A).copy()

tests/test_io.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_4D(backend, forward_output):
133133
np.arange(N[1], dtype=np.float)*2*np.pi/N[1],
134134
np.arange(N[2], dtype=np.float)*3*np.pi/N[2],
135135
np.arange(N[3], dtype=np.float)*4*np.pi/N[3]
136-
)
136+
)
137137
for i, domain in enumerate([None, d0, d1]):
138138
for rank in range(3):
139139
filename = "".join(('h5test4_{}{}{}'.format(ex[i == 0], ex[forward_output], rank),

0 commit comments

Comments
 (0)