Skip to content

Commit 2bb1af1

Browse files
committed
copilot fixes
1 parent 84331d6 commit 2bb1af1

7 files changed

Lines changed: 30 additions & 64 deletions

File tree

benchmarks/benchmarks/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727

2828
def _physical_cores():
29-
"""Return physical core count from /proc/cpuinfo; fall back to os.cpu_count()."""
29+
"""Return physical core count from /proc/cpuinfo; fall back to 1 (conservative)."""
3030
try:
3131
with open("/proc/cpuinfo") as f:
3232
content = f.read()
@@ -36,7 +36,7 @@ def _physical_cores():
3636
)
3737
return cpu_cores * sockets
3838
except Exception:
39-
return os.cpu_count() or 1
39+
return 1
4040

4141

4242
def _thread_count():

benchmarks/benchmarks/_utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""Shared utilities for mkl_fft benchmarks."""
2+
3+
import numpy as np
4+
5+
6+
def _make_input(rng, shape, dtype):
7+
"""Return an array of *shape* and *dtype*.
8+
9+
Complex dtypes get non-zero imaginary parts for a realistic signal.
10+
*shape* may be an int (1-D) or a tuple.
11+
"""
12+
dt = np.dtype(dtype)
13+
s = (shape,) if isinstance(shape, int) else shape
14+
if dt.kind == "c":
15+
return (rng.standard_normal(s) + 1j * rng.standard_normal(s)).astype(dt)
16+
return rng.standard_normal(s).astype(dt)

benchmarks/benchmarks/bench_fft1d.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,9 @@
44

55
import mkl_fft
66

7-
_RNG_SEED = 42
8-
9-
10-
def _make_input(rng, n, dtype):
11-
"""Return a 1-D array of length *n* with the given *dtype*.
7+
from ._utils import _make_input
128

13-
Complex dtypes are populated with non-zero imaginary parts so the
14-
benchmark exercises a genuine complex transform path.
15-
"""
16-
dt = np.dtype(dtype)
17-
if dt.kind == "c":
18-
return (rng.standard_normal(n) + 1j * rng.standard_normal(n)).astype(dt)
19-
return rng.standard_normal(n).astype(dt)
9+
_RNG_SEED = 42
2010

2111

2212
# ---------------------------------------------------------------------------

benchmarks/benchmarks/bench_fftnd.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,9 @@
44

55
import mkl_fft
66

7-
_RNG_SEED = 42
8-
7+
from ._utils import _make_input
98

10-
def _make_input(rng, shape, dtype):
11-
"""Return an array of the given *shape* and *dtype*.
12-
13-
Complex dtypes are populated with non-zero imaginary parts so the
14-
benchmark exercises a genuine complex transform path.
15-
"""
16-
dt = np.dtype(dtype)
17-
if dt.kind == "c":
18-
return (
19-
rng.standard_normal(shape) + 1j * rng.standard_normal(shape)
20-
).astype(dt)
21-
return rng.standard_normal(shape).astype(dt)
9+
_RNG_SEED = 42
2210

2311

2412
# ---------------------------------------------------------------------------

benchmarks/benchmarks/bench_memory.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,9 @@
88

99
import mkl_fft
1010

11-
_RNG_SEED = 42
12-
11+
from ._utils import _make_input
1312

14-
def _make_input(rng, shape, dtype):
15-
dt = np.dtype(dtype)
16-
s = (shape,) if isinstance(shape, int) else shape
17-
if dt.kind == "c":
18-
return (rng.standard_normal(s) + 1j * rng.standard_normal(s)).astype(dt)
19-
return rng.standard_normal(s).astype(dt)
13+
_RNG_SEED = 42
2014

2115

2216
# ---------------------------------------------------------------------------

benchmarks/benchmarks/bench_numpy_fft.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,9 @@
1414

1515
from mkl_fft.interfaces import numpy_fft
1616

17-
_RNG_SEED = 42
18-
19-
20-
def _make_input(rng, shape, dtype):
21-
"""Return an array of *shape* and *dtype*.
17+
from ._utils import _make_input
2218

23-
Complex dtypes get non-zero imaginary parts for a realistic signal.
24-
*shape* may be an int (1-D) or a tuple.
25-
"""
26-
dt = np.dtype(dtype)
27-
s = (shape,) if isinstance(shape, int) else shape
28-
if dt.kind == "c":
29-
return (rng.standard_normal(s) + 1j * rng.standard_normal(s)).astype(dt)
30-
return rng.standard_normal(s).astype(dt)
19+
_RNG_SEED = 42
3120

3221

3322
# ---------------------------------------------------------------------------
@@ -182,7 +171,7 @@ def time_irfft2(self, shape, dtype):
182171
# ---------------------------------------------------------------------------
183172

184173

185-
class TimeCCND:
174+
class TimeC2CND:
186175
"""numpy_fft.fftn / ifftn — N-D."""
187176

188177
params = [

benchmarks/benchmarks/bench_scipy_fft.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,9 @@
1616

1717
from mkl_fft.interfaces import scipy_fft
1818

19-
_RNG_SEED = 42
20-
21-
22-
def _make_input(rng, shape, dtype):
23-
"""Return an array of *shape* and *dtype*.
19+
from ._utils import _make_input
2420

25-
Complex dtypes get non-zero imaginary parts for a realistic signal.
26-
*shape* may be an int (1-D) or a tuple.
27-
"""
28-
dt = np.dtype(dtype)
29-
s = (shape,) if isinstance(shape, int) else shape
30-
if dt.kind == "c":
31-
return (rng.standard_normal(s) + 1j * rng.standard_normal(s)).astype(dt)
32-
return rng.standard_normal(s).astype(dt)
21+
_RNG_SEED = 42
3322

3423

3524
# ---------------------------------------------------------------------------
@@ -218,7 +207,7 @@ def time_ihfft2(self, shape, dtype):
218207
# ---------------------------------------------------------------------------
219208

220209

221-
class TimeCCND:
210+
class TimeC2CND:
222211
"""scipy_fft.fftn / ifftn — N-D."""
223212

224213
params = [

0 commit comments

Comments
 (0)