Skip to content

Commit 0e5506e

Browse files
authored
Modernize CI (#641)
* Update unit test action. * Remove docs build and replace it with ReadTheDocs CI. * Remove CodeQL job -- ruff is superior. * Add back docs job. * Remove erroneous CI snippet. * Add Array API tests. * Add Array API tests. * Remove tar-bz2-only and mamba in CI. * Add real and imag functions. * Remove array-api job to merge CI modernizations. * Fix some DeprecationWarnings.
1 parent cb6b604 commit 0e5506e

File tree

6 files changed

+27
-59
lines changed

6 files changed

+27
-59
lines changed

.github/workflows/ci.yml

+10-14
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
NUMBA_BOUNDSCHECK: ${{ matrix.numba_boundscheck }}
2424
steps:
2525
- name: Checkout Repo
26-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
2727
- name: Cache conda
28-
uses: actions/cache@v3
28+
uses: actions/cache@v4
2929
env:
3030
# Increase this value to reset cache if ci/environment.yml has not changed
3131
CACHE_NUMBER: 0
@@ -34,25 +34,23 @@ jobs:
3434
key:
3535
test-${{ matrix.os }}-conda-py${{ matrix.python }}-${{ env.CACHE_NUMBER }}-${{
3636
hashFiles('ci/environment.yml') }}
37-
- uses: conda-incubator/setup-miniconda@v2
37+
- uses: conda-incubator/setup-miniconda@v3
3838
with:
3939
activate-environment: sparse-dev
4040
allow-softlinks: true
4141
environment-file: ci/environment.yml
4242
python-version: ${{ matrix.python }}
43-
miniforge-variant: Mambaforge
44-
use-only-tar-bz2: true
45-
use-mamba: true
43+
miniforge-version: latest
4644
- name: Install package
4745
run: |
4846
pip install -e .[tests]
4947
- name: Run tests
5048
run: |
5149
pytest --pyargs sparse
52-
- uses: codecov/codecov-action@v3
50+
- uses: codecov/codecov-action@v4
5351
if: always()
54-
- name: Publish Unit Test Results
55-
uses: EnricoMi/publish-unit-test-result-action/composite@v1
52+
- name: Publish Test Results
53+
uses: EnricoMi/publish-unit-test-result-action/composite@v2
5654
if: always()
5755
with:
5856
files: "**/test-*.xml"
@@ -63,9 +61,9 @@ jobs:
6361
runs-on: ubuntu-latest
6462
steps:
6563
- name: Checkout Repo
66-
uses: actions/checkout@v3
64+
uses: actions/checkout@v4
6765
- name: Cache conda
68-
uses: actions/cache@v3
66+
uses: actions/cache@v4
6967
env:
7068
# Increase this value to reset cache if ci/environment.yml has not changed
7169
CACHE_NUMBER: 0
@@ -80,15 +78,13 @@ jobs:
8078
environment-file: ci/environment.yml
8179
python-version: '3.10'
8280
miniforge-version: latest
83-
use-only-tar-bz2: true
84-
use-mamba: true
8581
- name: Install package
8682
run: |
8783
pip install -e .[docs]
8884
- name: Run tests
8985
run: |
9086
sphinx-build -W -b html docs/ _build/html
91-
- uses: actions/upload-artifact@v1
87+
- uses: actions/upload-artifact@v4
9288
with:
9389
name: Documentation
9490
path: _build/html

.github/workflows/codeql.yml

-41
This file was deleted.

sparse/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
greater,
2424
greater_equal,
2525
iinfo,
26+
imag,
2627
inf,
2728
int8,
2829
int16,
@@ -46,6 +47,7 @@
4647
not_equal,
4748
pi,
4849
positive,
50+
real,
4951
remainder,
5052
sign,
5153
sin,
@@ -228,6 +230,7 @@
228230
"greater",
229231
"greater_equal",
230232
"iinfo",
233+
"imag",
231234
"inf",
232235
"int16",
233236
"int32",
@@ -279,6 +282,7 @@
279282
"pow",
280283
"prod",
281284
"random",
285+
"real",
282286
"remainder",
283287
"reshape",
284288
"result_type",

sparse/_sparse_array.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def _repr_html_(self):
172172
from matrepr.adapters.sparse_driver import PyDataSparseDriver
173173

174174
return to_html(PyDataSparseDriver.adapt(self), notebook=True)
175-
except ImportError:
175+
except (ImportError, ValueError):
176176
return html_table(self)
177177

178178
def _str_impl(self, summary):
@@ -203,7 +203,7 @@ def _str_impl(self, summary):
203203
max_cols=9999,
204204
)
205205
return f"{summary}\n{values}"
206-
except ImportError:
206+
except (ImportError, ValueError):
207207
return summary
208208

209209
@abstractmethod

sparse/_utils.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import functools
22
import operator
3+
import warnings
34
from collections.abc import Iterable
45
from functools import reduce
56
from numbers import Integral
@@ -616,11 +617,17 @@ def get_out_dtype(arr, scalar):
616617

617618

618619
def can_store(dtype, scalar):
619-
return np.array(scalar, dtype=dtype) == np.array(scalar)
620+
try:
621+
with warnings.catch_warnings():
622+
warnings.simplefilter("ignore")
623+
warnings.filterwarnings("error", "out-of-bound", DeprecationWarning)
624+
return np.array(scalar, dtype=dtype) == np.array(scalar)
625+
except ValueError:
626+
return False
620627

621628

622629
def is_unsigned_dtype(dtype):
623-
return np.array(-1, dtype=dtype) != np.array(-1)
630+
return np.issubdtype(dtype, np.integer) and np.iinfo(dtype).min == 0
624631

625632

626633
def convert_format(format):

sparse/tests/test_namespace.py

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def test_namespace():
7171
"greater",
7272
"greater_equal",
7373
"iinfo",
74+
"imag",
7475
"inf",
7576
"int16",
7677
"int32",
@@ -122,6 +123,7 @@ def test_namespace():
122123
"pow",
123124
"prod",
124125
"random",
126+
"real",
125127
"remainder",
126128
"reshape",
127129
"result_type",

0 commit comments

Comments
 (0)