Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and mtsokol committed Jan 7, 2024
1 parent a1a6aee commit 28a16b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 4 additions & 3 deletions sparse/_coo/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,7 @@ def clip(a, a_min=None, a_max=None, out=None):

# Array API set functions


class UniqueCountsResult(NamedTuple):
values: np.ndarray
counts: np.ndarray
Expand Down Expand Up @@ -1098,7 +1099,7 @@ def unique_counts(x, /):
from .core import COO

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
sparse._coo.core
begins an import cycle.

if not isinstance(x, COO):
raise ValueError(f"Only COO arrays are supported but {type(x)} was passed.")
x = x.asformat(COO)

x = x.flatten()
values, counts = np.unique(x.data, return_counts=True)
Expand Down Expand Up @@ -1141,7 +1142,7 @@ def unique_values(x, /):
from .core import COO

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
sparse._coo.core
begins an import cycle.

if not isinstance(x, COO):
raise ValueError(f"Only COO arrays are supported but {type(x)} was passed.")
x = x.asformat(COO)

x = x.flatten()
values = np.unique(x.data)
Expand Down Expand Up @@ -1213,7 +1214,7 @@ def _arg_minmax_common(
from .core import COO

if not isinstance(x, COO):
raise ValueError(f"Only COO arrays are supported but {type(x)} was passed.")
x = x.asformat(COO)

Check warning on line 1217 in sparse/_coo/common.py

View check run for this annotation

Codecov / codecov/patch

sparse/_coo/common.py#L1217

Added line #L1217 was not covered by tests

if not isinstance(axis, (int, type(None))):
raise ValueError(f"`axis` must be `int` or `None`, but it's: {type(axis)}.")
Expand Down
6 changes: 2 additions & 4 deletions sparse/tests/test_coo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1773,9 +1773,7 @@ def test_unique_values(self, arr, fill_value):

np.testing.assert_equal(result, expected)

@pytest.mark.parametrize(
"func", [sparse.unique_counts, sparse.unique_values]
)
@pytest.mark.parametrize("func", [sparse.unique_counts, sparse.unique_values])
def test_input_validation(self, func):
with pytest.raises(ValueError, match=r"Only COO arrays are supported"):
with pytest.raises(AttributeError, match=r"object has no attribute 'asformat'"):
func(self.arr)

0 comments on commit 28a16b6

Please sign in to comment.