Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize CI #641

Merged
merged 13 commits into from
Mar 4, 2024
24 changes: 10 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
NUMBA_BOUNDSCHECK: ${{ matrix.numba_boundscheck }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Cache conda
uses: actions/cache@v3
uses: actions/cache@v4
env:
# Increase this value to reset cache if ci/environment.yml has not changed
CACHE_NUMBER: 0
Expand All @@ -34,25 +34,23 @@ jobs:
key:
test-${{ matrix.os }}-conda-py${{ matrix.python }}-${{ env.CACHE_NUMBER }}-${{
hashFiles('ci/environment.yml') }}
- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: sparse-dev
allow-softlinks: true
environment-file: ci/environment.yml
python-version: ${{ matrix.python }}
miniforge-variant: Mambaforge
use-only-tar-bz2: true
use-mamba: true
miniforge-version: latest
- name: Install package
run: |
pip install -e .[tests]
- name: Run tests
run: |
pytest --pyargs sparse
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
if: always()
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action/composite@v1
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always()
with:
files: "**/test-*.xml"
Expand All @@ -63,9 +61,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Cache conda
uses: actions/cache@v3
uses: actions/cache@v4
env:
# Increase this value to reset cache if ci/environment.yml has not changed
CACHE_NUMBER: 0
Expand All @@ -80,15 +78,13 @@ jobs:
environment-file: ci/environment.yml
python-version: '3.10'
miniforge-version: latest
use-only-tar-bz2: true
use-mamba: true
- name: Install package
run: |
pip install -e .[docs]
- name: Run tests
run: |
sphinx-build -W -b html docs/ _build/html
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v4
with:
name: Documentation
path: _build/html
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/codeql.yml

This file was deleted.

4 changes: 4 additions & 0 deletions sparse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
greater,
greater_equal,
iinfo,
imag,
inf,
int8,
int16,
Expand All @@ -46,6 +47,7 @@
not_equal,
pi,
positive,
real,
remainder,
sign,
sin,
Expand Down Expand Up @@ -228,6 +230,7 @@
"greater",
"greater_equal",
"iinfo",
"imag",
"inf",
"int16",
"int32",
Expand Down Expand Up @@ -279,6 +282,7 @@
"pow",
"prod",
"random",
"real",
"remainder",
"reshape",
"result_type",
Expand Down
4 changes: 2 additions & 2 deletions sparse/_sparse_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _repr_html_(self):
from matrepr.adapters.sparse_driver import PyDataSparseDriver

return to_html(PyDataSparseDriver.adapt(self), notebook=True)
except ImportError:
except (ImportError, ValueError):
return html_table(self)

def _str_impl(self, summary):
Expand Down Expand Up @@ -203,7 +203,7 @@ def _str_impl(self, summary):
max_cols=9999,
)
return f"{summary}\n{values}"
except ImportError:
except (ImportError, ValueError):
return summary

@abstractmethod
Expand Down
11 changes: 9 additions & 2 deletions sparse/_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import functools
import operator
import warnings
from collections.abc import Iterable
from functools import reduce
from numbers import Integral
Expand Down Expand Up @@ -616,11 +617,17 @@ def get_out_dtype(arr, scalar):


def can_store(dtype, scalar):
return np.array(scalar, dtype=dtype) == np.array(scalar)
try:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
warnings.filterwarnings("error", "out-of-bound", DeprecationWarning)
return np.array(scalar, dtype=dtype) == np.array(scalar)
except ValueError:
return False


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


def convert_format(format):
Expand Down
2 changes: 2 additions & 0 deletions sparse/tests/test_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_namespace():
"greater",
"greater_equal",
"iinfo",
"imag",
"inf",
"int16",
"int32",
Expand Down Expand Up @@ -122,6 +123,7 @@ def test_namespace():
"pow",
"prod",
"random",
"real",
"remainder",
"reshape",
"result_type",
Expand Down
Loading