Skip to content

Commit 20e693a

Browse files
authored
MNT: sparse import refactor (#695)
* MNT: `sparse` import refactor * Add missing imports * Refactor sparse/__init__.py * Disable Finch backend in asv
1 parent 38d1a67 commit 20e693a

File tree

15 files changed

+176
-368
lines changed

15 files changed

+176
-368
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ jobs:
5353
pip install ${{ matrix.pip_opts }} numpy numba
5454
- name: Run tests
5555
run: |
56-
pytest --pyargs sparse
56+
SPARSE_BACKEND=Numba pytest --pyargs sparse
57+
SPARSE_BACKEND=Finch pytest --pyargs sparse/tests
5758
- uses: codecov/codecov-action@v4
5859
if: always()
5960
- name: Publish Test Results

asv.conf.json

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,17 @@
44
],
55
"build_command": [],
66
"environment_type": "virtualenv",
7-
"exclude": [
8-
{
9-
"env": {
10-
"SPARSE_BACKEND": "Finch"
11-
},
12-
"req": {
13-
"finch-tensor": null
14-
}
15-
},
16-
{
17-
"env": {
18-
"SPARSE_BACKEND": "Numba"
19-
},
20-
"req": {
21-
"finch-tensor": ""
22-
}
23-
}
24-
],
257
"install_command": [
268
"pip install --no-deps ."
279
],
2810
"matrix": {
2911
"env": {
3012
"SPARSE_BACKEND": [
31-
"Finch",
3213
"Numba"
3314
]
3415
},
3516
"env_nobuild": {},
3617
"req": {
37-
"finch-tensor": [
38-
"",
39-
null
40-
],
4118
"numba": [
4219
""
4320
],

benchmarks/benchmark_backends.py

Lines changed: 0 additions & 140 deletions
This file was deleted.

benchmarks/benchmark_coo.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
import numpy as np
44

5-
from .utils import skip_if_finch
6-
75

86
class MatrixMultiplySuite:
97
def setup(self):
10-
skip_if_finch()
11-
128
rng = np.random.default_rng(0)
139
self.x = sparse.random((100, 100), density=0.01, random_state=rng)
1410
self.y = sparse.random((100, 100), density=0.01, random_state=rng)
@@ -21,8 +17,6 @@ def time_matmul(self):
2117

2218
class ElemwiseSuite:
2319
def setup(self):
24-
skip_if_finch()
25-
2620
rng = np.random.default_rng(0)
2721
self.x = sparse.random((100, 100, 100), density=0.01, random_state=rng)
2822
self.y = sparse.random((100, 100, 100), density=0.01, random_state=rng)
@@ -39,8 +33,6 @@ def time_mul(self):
3933

4034
class ElemwiseBroadcastingSuite:
4135
def setup(self):
42-
skip_if_finch()
43-
4436
rng = np.random.default_rng(0)
4537
self.x = sparse.random((100, 1, 100), density=0.01, random_state=rng)
4638
self.y = sparse.random((100, 100), density=0.01, random_state=rng)
@@ -57,8 +49,6 @@ def time_mul(self):
5749

5850
class IndexingSuite:
5951
def setup(self):
60-
skip_if_finch()
61-
6252
rng = np.random.default_rng(0)
6353
self.index = rng.integers(0, 100, 50)
6454
self.x = sparse.random((100, 100, 100), density=0.01, random_state=rng)

benchmarks/benchmark_gcxs.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
import numpy as np
44

5-
from .utils import skip_if_finch
6-
75

86
class MatrixMultiplySuite:
97
def setup(self):
10-
skip_if_finch()
11-
128
rng = np.random.default_rng(0)
139
self.x = sparse.random((100, 100), density=0.01, format="gcxs", random_state=rng)
1410
self.y = sparse.random((100, 100), density=0.01, format="gcxs", random_state=rng)
@@ -21,8 +17,6 @@ def time_matmul(self):
2117

2218
class ElemwiseSuite:
2319
def setup(self):
24-
skip_if_finch()
25-
2620
rng = np.random.default_rng(0)
2721
self.x = sparse.random((100, 100, 100), density=0.01, format="gcxs", random_state=rng)
2822
self.y = sparse.random((100, 100, 100), density=0.01, format="gcxs", random_state=rng)
@@ -38,8 +32,6 @@ def time_mul(self):
3832

3933
class ElemwiseBroadcastingSuite:
4034
def setup(self):
41-
skip_if_finch()
42-
4335
rng = np.random.default_rng(0)
4436
self.x = sparse.random((100, 1, 100), density=0.01, format="gcxs", random_state=rng)
4537
self.y = sparse.random((100, 100), density=0.01, format="gcxs", random_state=rng)
@@ -53,8 +45,6 @@ def time_mul(self):
5345

5446
class IndexingSuite:
5547
def setup(self):
56-
skip_if_finch()
57-
5848
rng = np.random.default_rng(0)
5949
self.index = rng.integers(0, 100, 50)
6050
self.x = sparse.random((100, 100, 100), density=0.01, format="gcxs", random_state=rng)
@@ -84,8 +74,6 @@ class DenseMultiplySuite:
8474
param_names = ["compressed axis", "n_vectors"]
8575

8676
def setup(self, compressed_axis, n_vecs):
87-
skip_if_finch()
88-
8977
rng = np.random.default_rng(1337)
9078
n = 10000
9179
x = sparse.random((n, n), density=0.001, format="gcxs", random_state=rng).change_compressed_axes(

benchmarks/benchmark_matmul.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22

33
import numpy as np
44

5-
from .utils import skip_if_finch
6-
75

86
class Matmul_Sparse:
97
params = (["coo", "gcxs"], [0, 1, None])
108

119
def setup(self, p, dens_arg):
12-
skip_if_finch()
13-
1410
rng = np.random.default_rng(0)
1511
self.x = sparse.random((100, 100), density=0.01, format=p, random_state=rng)
1612
self.y = sparse.random((100, 100), density=0.01, format=p, random_state=rng)

benchmarks/benchmark_tensordot.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import numpy as np
44

5-
from .utils import skip_if_finch
6-
75

86
class TensordotSuiteDenseSparse:
97
"""
@@ -12,8 +10,6 @@ class TensordotSuiteDenseSparse:
1210
"""
1311

1412
def setup(self):
15-
skip_if_finch()
16-
1713
rng = np.random.default_rng(0)
1814
self.n = rng.random((100, 100))
1915
self.s = sparse.random((100, 100, 100, 100), density=0.01, random_state=rng)
@@ -32,8 +28,6 @@ class TensordotSuiteSparseSparse:
3228
"""
3329

3430
def setup(self):
35-
skip_if_finch()
36-
3731
rng = np.random.default_rng(0)
3832
self.s1 = sparse.random((100, 100), density=0.01, random_state=rng)
3933
self.s2 = sparse.random((100, 100, 100, 100), density=0.01, random_state=rng)
@@ -52,8 +46,6 @@ class TensordotSuiteSparseDense:
5246
"""
5347

5448
def setup(self):
55-
skip_if_finch()
56-
5749
rng = np.random.default_rng(0)
5850
self.s = sparse.random((100, 100, 100, 100), density=0.01, random_state=rng)
5951
self.n = rng.random((100, 100))

benchmarks/utils.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)