Skip to content

Commit c05764a

Browse files
committed
Apply black style checks
1 parent 923a022 commit c05764a

File tree

8 files changed

+189
-58
lines changed

8 files changed

+189
-58
lines changed

mkl_fft/_numpy_fft.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,9 @@ def irfft(a, n=None, axis=-1, norm=None):
512512
else:
513513
fsc = ortho_sc_1d(nn, nn)
514514

515-
return trycall(mkl_fft.irfft, (x,), {"n": n, "axis": axis, "fwd_scale": fsc})
515+
return trycall(
516+
mkl_fft.irfft, (x,), {"n": n, "axis": axis, "fwd_scale": fsc}
517+
)
516518

517519

518520
def hfft(a, n=None, axis=-1, norm=None):
@@ -604,7 +606,9 @@ def hfft(a, n=None, axis=-1, norm=None):
604606
else:
605607
fsc = ortho_sc_1d(nn, nn)
606608

607-
return trycall(mkl_fft.irfft, (x,), {"n": n, "axis": axis, "fwd_scale": fsc})
609+
return trycall(
610+
mkl_fft.irfft, (x,), {"n": n, "axis": axis, "fwd_scale": fsc}
611+
)
608612

609613

610614
def ihfft(a, n=None, axis=-1, norm=None):
@@ -676,7 +680,9 @@ def ihfft(a, n=None, axis=-1, norm=None):
676680
else:
677681
fsc = ortho_sc_1d(n, x.shape[axis])
678682

679-
output = trycall(mkl_fft.rfft, (x,), {"n": n, "axis": axis, "fwd_scale": fsc})
683+
output = trycall(
684+
mkl_fft.rfft, (x,), {"n": n, "axis": axis, "fwd_scale": fsc}
685+
)
680686

681687
conjugate(output, out=output)
682688
return output
@@ -922,7 +928,9 @@ def ifftn(a, s=None, axes=None, norm=None):
922928
else:
923929
fsc = sqrt(frwd_sc_nd(s, x.shape))
924930

925-
return trycall(mkl_fft.ifftn, (x,), {"s": s, "axes": axes, "fwd_scale": fsc})
931+
return trycall(
932+
mkl_fft.ifftn, (x,), {"s": s, "axes": axes, "fwd_scale": fsc}
933+
)
926934

927935

928936
def fft2(a, s=None, axes=(-2, -1), norm=None):
@@ -1219,7 +1227,9 @@ def rfftn(a, s=None, axes=None, norm=None):
12191227
s, axes = _cook_nd_args(x, s, axes)
12201228
fsc = sqrt(frwd_sc_nd(s, x.shape))
12211229

1222-
return trycall(mkl_fft.rfftn, (x,), {"s": s, "axes": axes, "fwd_scale": fsc})
1230+
return trycall(
1231+
mkl_fft.rfftn, (x,), {"s": s, "axes": axes, "fwd_scale": fsc}
1232+
)
12231233

12241234

12251235
def rfft2(a, s=None, axes=(-2, -1), norm=None):
@@ -1371,7 +1381,9 @@ def irfftn(a, s=None, axes=None, norm=None):
13711381
s, axes = _cook_nd_args(x, s, axes, invreal=1)
13721382
fsc = sqrt(frwd_sc_nd(s, x.shape))
13731383

1374-
return trycall(mkl_fft.irfftn, (x,), {"s": s, "axes": axes, "fwd_scale": fsc})
1384+
return trycall(
1385+
mkl_fft.irfftn, (x,), {"s": s, "axes": axes, "fwd_scale": fsc}
1386+
)
13751387

13761388

13771389
def irfft2(a, s=None, axes=(-2, -1), norm=None):

mkl_fft/_scipy_fft.py

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ def _compute_nd_fwd_scale(norm, s, axes, x_shape):
267267
return fsc
268268

269269

270-
def fft(a, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, plan=None):
270+
def fft(
271+
a, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, plan=None
272+
):
271273
try:
272274
x = _float_utils.__supported_array_or_not_implemented(a)
273275
except ValueError:
@@ -277,11 +279,15 @@ def fft(a, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, plan=Non
277279
fsc = _compute_1d_fwd_scale(norm, n, x.shape[axis])
278280
_check_plan(plan)
279281
with Workers(workers):
280-
output = mkl_fft.fft(x, n=n, axis=axis, overwrite_x=overwrite_x, fwd_scale=fsc)
282+
output = mkl_fft.fft(
283+
x, n=n, axis=axis, overwrite_x=overwrite_x, fwd_scale=fsc
284+
)
281285
return output
282286

283287

284-
def ifft(a, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, plan=None):
288+
def ifft(
289+
a, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, plan=None
290+
):
285291
try:
286292
x = _float_utils.__supported_array_or_not_implemented(a)
287293
except ValueError:
@@ -291,12 +297,20 @@ def ifft(a, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, plan=No
291297
fsc = _compute_1d_fwd_scale(norm, n, x.shape[axis])
292298
_check_plan(plan)
293299
with Workers(workers):
294-
output = mkl_fft.ifft(x, n=n, axis=axis, overwrite_x=overwrite_x, fwd_scale=fsc)
300+
output = mkl_fft.ifft(
301+
x, n=n, axis=axis, overwrite_x=overwrite_x, fwd_scale=fsc
302+
)
295303
return output
296304

297305

298306
def fft2(
299-
a, s=None, axes=(-2, -1), norm=None, overwrite_x=False, workers=None, plan=None
307+
a,
308+
s=None,
309+
axes=(-2, -1),
310+
norm=None,
311+
overwrite_x=False,
312+
workers=None,
313+
plan=None,
300314
):
301315
try:
302316
x = _float_utils.__supported_array_or_not_implemented(a)
@@ -307,12 +321,20 @@ def fft2(
307321
fsc = _compute_nd_fwd_scale(norm, s, axes, x.shape)
308322
_check_plan(plan)
309323
with Workers(workers):
310-
output = mkl_fft.fftn(x, s=s, axes=axes, overwrite_x=overwrite_x, fwd_scale=fsc)
324+
output = mkl_fft.fftn(
325+
x, s=s, axes=axes, overwrite_x=overwrite_x, fwd_scale=fsc
326+
)
311327
return output
312328

313329

314330
def ifft2(
315-
a, s=None, axes=(-2, -1), norm=None, overwrite_x=False, workers=None, plan=None
331+
a,
332+
s=None,
333+
axes=(-2, -1),
334+
norm=None,
335+
overwrite_x=False,
336+
workers=None,
337+
plan=None,
316338
):
317339
try:
318340
x = _float_utils.__supported_array_or_not_implemented(a)
@@ -329,7 +351,9 @@ def ifft2(
329351
return output
330352

331353

332-
def fftn(a, s=None, axes=None, norm=None, overwrite_x=False, workers=None, plan=None):
354+
def fftn(
355+
a, s=None, axes=None, norm=None, overwrite_x=False, workers=None, plan=None
356+
):
333357
try:
334358
x = _float_utils.__supported_array_or_not_implemented(a)
335359
except ValueError:
@@ -339,11 +363,15 @@ def fftn(a, s=None, axes=None, norm=None, overwrite_x=False, workers=None, plan=
339363
fsc = _compute_nd_fwd_scale(norm, s, axes, x.shape)
340364
_check_plan(plan)
341365
with Workers(workers):
342-
output = mkl_fft.fftn(x, s=s, axes=axes, overwrite_x=overwrite_x, fwd_scale=fsc)
366+
output = mkl_fft.fftn(
367+
x, s=s, axes=axes, overwrite_x=overwrite_x, fwd_scale=fsc
368+
)
343369
return output
344370

345371

346-
def ifftn(a, s=None, axes=None, norm=None, overwrite_x=False, workers=None, plan=None):
372+
def ifftn(
373+
a, s=None, axes=None, norm=None, overwrite_x=False, workers=None, plan=None
374+
):
347375
try:
348376
x = _float_utils.__supported_array_or_not_implemented(a)
349377
except ValueError:
@@ -423,7 +451,9 @@ def irfft2(a, s=None, axes=(-2, -1), norm=None, workers=None, plan=None):
423451
return NotImplemented
424452
if x is NotImplemented:
425453
return x
426-
s, axes, fsc = _compute_nd_fwd_scale_for_rfft(norm, s, axes, x, invreal=True)
454+
s, axes, fsc = _compute_nd_fwd_scale_for_rfft(
455+
norm, s, axes, x, invreal=True
456+
)
427457
_check_plan(plan)
428458
with Workers(workers):
429459
output = mkl_fft.irfftn(x, s, axes, fwd_scale=fsc)
@@ -451,7 +481,9 @@ def irfftn(a, s=None, axes=None, norm=None, workers=None, plan=None):
451481
return NotImplemented
452482
if x is NotImplemented:
453483
return x
454-
s, axes, fsc = _compute_nd_fwd_scale_for_rfft(norm, s, axes, x, invreal=True)
484+
s, axes, fsc = _compute_nd_fwd_scale_for_rfft(
485+
norm, s, axes, x, invreal=True
486+
)
455487
_check_plan(plan)
456488
with Workers(workers):
457489
output = mkl_fft.irfftn(x, s, axes, fwd_scale=fsc)

mkl_fft/tests/test_fft1d.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def setUp(self):
5555
rnd.seed(1234567)
5656
self.xd1 = rnd.standard_normal(128)
5757
self.xf1 = self.xd1.astype(np.float32)
58-
self.xz1 = rnd.standard_normal((128, 2)).view(dtype=np.complex128).squeeze()
58+
self.xz1 = (
59+
rnd.standard_normal((128, 2)).view(dtype=np.complex128).squeeze()
60+
)
5961
self.xc1 = self.xz1.astype(np.complex64)
6062

6163
def test_vector1(self):

mkl_fft/tests/test_fftnd.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,14 @@ def test_cf_contig(self):
192192

193193
def test_rfftn(self):
194194
"""Test that rfftn works as expected"""
195-
axes = [(0, 1, 2), (0, 2, 1), (1, 0, 2), (1, 2, 0), (2, 0, 1), (2, 1, 0)]
195+
axes = [
196+
(0, 1, 2),
197+
(0, 2, 1),
198+
(1, 0, 2),
199+
(1, 2, 0),
200+
(2, 0, 1),
201+
(2, 1, 0),
202+
]
196203
for x in [self.ad, self.af]:
197204
for a in axes:
198205
r_tol, a_tol = _get_rtol_atol(x)
@@ -274,7 +281,9 @@ def test_gh109():
274281
b = np.asarray(b_int, dtype=np.float32)
275282

276283
r1 = mkl_fft.fftn(b, s=None, axes=(0,), overwrite_x=False, fwd_scale=1 / 3)
277-
r2 = mkl_fft.fftn(b_int, s=None, axes=(0,), overwrite_x=False, fwd_scale=1 / 3)
284+
r2 = mkl_fft.fftn(
285+
b_int, s=None, axes=(0,), overwrite_x=False, fwd_scale=1 / 3
286+
)
278287

279288
rtol, atol = _get_rtol_atol(b)
280289
assert_allclose(r1, r2, rtol=rtol, atol=atol)

mkl_fft/tests/test_interfaces.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030

3131

3232
@pytest.mark.parametrize("norm", [None, "forward", "backward", "ortho"])
33-
@pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128])
33+
@pytest.mark.parametrize(
34+
"dtype", [np.float32, np.float64, np.complex64, np.complex128]
35+
)
3436
def test_scipy_fft(norm, dtype):
3537
x = np.ones(511, dtype=dtype)
3638
w = mfi.scipy_fft.fft(x, norm=norm, workers=None, plan=None)
@@ -40,7 +42,9 @@ def test_scipy_fft(norm, dtype):
4042

4143

4244
@pytest.mark.parametrize("norm", [None, "forward", "backward", "ortho"])
43-
@pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128])
45+
@pytest.mark.parametrize(
46+
"dtype", [np.float32, np.float64, np.complex64, np.complex128]
47+
)
4448
def test_numpy_fft(norm, dtype):
4549
x = np.ones(511, dtype=dtype)
4650
w = mfi.numpy_fft.fft(x, norm=norm)
@@ -54,7 +58,9 @@ def test_numpy_fft(norm, dtype):
5458
def test_scipy_rfft(norm, dtype):
5559
x = np.ones(511, dtype=dtype)
5660
w = mfi.scipy_fft.rfft(x, norm=norm, workers=None, plan=None)
57-
xx = mfi.scipy_fft.irfft(w, n=x.shape[0], norm=norm, workers=None, plan=None)
61+
xx = mfi.scipy_fft.irfft(
62+
w, n=x.shape[0], norm=norm, workers=None, plan=None
63+
)
5864
tol = 64 * np.finfo(np.dtype(dtype)).eps
5965
assert np.allclose(x, xx, atol=tol, rtol=tol)
6066

@@ -76,7 +82,9 @@ def test_numpy_rfft(norm, dtype):
7682

7783

7884
@pytest.mark.parametrize("norm", [None, "forward", "backward", "ortho"])
79-
@pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128])
85+
@pytest.mark.parametrize(
86+
"dtype", [np.float32, np.float64, np.complex64, np.complex128]
87+
)
8088
def test_scipy_fftn(norm, dtype):
8189
x = np.ones((37, 83), dtype=dtype)
8290
w = mfi.scipy_fft.fftn(x, norm=norm, workers=None, plan=None)
@@ -86,7 +94,9 @@ def test_scipy_fftn(norm, dtype):
8694

8795

8896
@pytest.mark.parametrize("norm", [None, "forward", "backward", "ortho"])
89-
@pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128])
97+
@pytest.mark.parametrize(
98+
"dtype", [np.float32, np.float64, np.complex64, np.complex128]
99+
)
90100
def test_numpy_fftn(norm, dtype):
91101
x = np.ones((37, 83), dtype=dtype)
92102
w = mfi.numpy_fft.fftn(x, norm=norm)

0 commit comments

Comments
 (0)