Skip to content

Commit f828ba9

Browse files
committed
After pre-commit
2 parents e6eed2e + ab21082 commit f828ba9

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

benchmarks/conftest.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import pytest
2-
import os
31
import sparse
42

3+
import pytest
4+
5+
56
@pytest.fixture
67
def seed(scope="session"):
78
return 42
@@ -11,16 +12,17 @@ def get_backend_id(param):
1112
backend = param
1213
return f"{backend=}"
1314

15+
1416
@pytest.fixture(params=[sparse._BACKEND.value], autouse=True, ids=get_backend_id)
1517
def backend(request):
16-
1718
return request.param
18-
19+
1920

2021
@pytest.fixture
2122
def min_size(scope="session"):
2223
return 50
2324

25+
2426
@pytest.fixture
2527
def max_size(scope="session"):
2628
return 2**26

benchmarks/test_benchmark_coo.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,20 @@
1313
def format_id(format):
1414
return f"{format=}"
1515

16+
1617
@pytest.mark.parametrize("format", ["coo", "gcxs"])
1718
def test_matmul(benchmark, sides, seed, format, backend, min_size, max_size, ids=format_id):
18-
1919
m, n, p = sides
20-
20+
2121
if m * n >= max_size or n * p >= max_size or m * n <= min_size or n * p <= min_size:
2222
pytest.skip()
23-
23+
2424
rng = np.random.default_rng(seed=seed)
2525
x = sparse.random((m, n), density=DENSITY, format=format, random_state=rng)
2626
y = sparse.random((n, p), density=DENSITY, format=format, random_state=rng)
27-
28-
if hasattr(sparse, "compiled"): operator.matmul = sparse.compiled(operator.matmul)
27+
28+
if hasattr(sparse, "compiled"):
29+
operator.matmul = sparse.compiled(operator.matmul)
2930

3031
x @ y # Numba compilation
3132

@@ -55,8 +56,9 @@ def elemwise_args(request, seed, max_size):
5556
def test_elemwise(benchmark, f, elemwise_args, backend):
5657
x, y = elemwise_args
5758

58-
if hasattr(sparse, "compiled"): f = sparse.compiled(f)
59-
59+
if hasattr(sparse, "compiled"):
60+
f = sparse.compiled(f)
61+
6062
f(x, y)
6163

6264
@benchmark
@@ -84,7 +86,8 @@ def elemwise_broadcast_args(request, seed, max_size):
8486
def test_elemwise_broadcast(benchmark, f, elemwise_broadcast_args):
8587
x, y = elemwise_broadcast_args
8688

87-
if hasattr(sparse, "compiled"): f = sparse.compiled(f)
89+
if hasattr(sparse, "compiled"):
90+
f = sparse.compiled(f)
8891

8992
f(x, y)
9093

@@ -109,7 +112,8 @@ def test_index_scalar(benchmark, indexing_args):
109112
side = x.shape[0]
110113
rank = x.ndim
111114

112-
if hasattr(sparse, "compiled"): operator.getitem = sparse.compiled(operator.getitem)
115+
if hasattr(sparse, "compiled"):
116+
operator.getitem = sparse.compiled(operator.getitem)
113117

114118
x[(side // 2,) * rank] # Numba compilation
115119

@@ -123,7 +127,8 @@ def test_index_slice(benchmark, indexing_args):
123127
side = x.shape[0]
124128
rank = x.ndim
125129

126-
if hasattr(sparse, "compiled"): operator.getitem = sparse.compiled(operator.getitem)
130+
if hasattr(sparse, "compiled"):
131+
operator.getitem = sparse.compiled(operator.getitem)
127132

128133
x[(slice(side // 2),) * rank] # Numba compilation
129134

@@ -138,7 +143,8 @@ def test_index_fancy(benchmark, indexing_args, seed):
138143
rng = np.random.default_rng(seed=seed)
139144
index = rng.integers(0, side, size=(side // 2,))
140145

141-
if hasattr(sparse, "compiled"): operator.getitem = sparse.compiled(operator.getitem)
146+
if hasattr(sparse, "compiled"):
147+
operator.getitem = sparse.compiled(operator.getitem)
142148

143149
x[index] # Numba compilation
144150

@@ -179,7 +185,8 @@ def densemul_args(request, sides, seed, max_size):
179185
def test_gcxs_dot_ndarray(benchmark, densemul_args):
180186
x, t = densemul_args
181187

182-
if hasattr(sparse, "compiled"): operator.matmul = sparse.compiled(operator.matmul)
188+
if hasattr(sparse, "compiled"):
189+
operator.matmul = sparse.compiled(operator.matmul)
183190

184191
# Numba compilation
185192
x @ t

0 commit comments

Comments
 (0)