Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: trailing-whitespace
- id: no-commit-to-branch
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.13.1
rev: v0.13.2
hooks:
- id: ruff-check
args: [--fix, --exit-non-zero-on-fix]
Expand Down
2 changes: 1 addition & 1 deletion src/fast_array_utils/stats/_is_constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _is_constant_cs(a: types.CSBase, /, *, axis: Literal[0, 1] | None = None) ->
n_row, n_col = a.shape
if axis is None:
if len(a.data) == n_row * n_col:
return is_constant(cast("NDArray[Any]", a.data))
return is_constant(a.data)
return bool((a.data == 0).all())
shape = (n_row, n_col) if axis == 1 else (n_col, n_row)
match axis, a.format:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def test_mean(array_type: ArrayType[Array], axis: Literal[0, 1] | None, np_arr:
if isinstance(result, types.CupyArray | types.CupyCSMatrix):
result = result.get()

expected = np.mean(np_arr, axis=axis) # type: ignore[arg-type]
expected = np.mean(np_arr, axis=axis)
np.testing.assert_array_equal(result, expected)


Expand All @@ -209,8 +209,8 @@ def test_mean_var(
if isinstance(mean, types.CupyArray) and isinstance(var, types.CupyArray):
mean, var = mean.get(), var.get()

mean_expected = np.mean(np_arr, axis=axis) # type: ignore[arg-type]
var_expected = np.var(np_arr, axis=axis, ddof=1) # type: ignore[arg-type]
mean_expected = np.mean(np_arr, axis=axis)
var_expected = np.var(np_arr, axis=axis, ddof=1)
np.testing.assert_array_equal(mean, mean_expected)
np.testing.assert_array_almost_equal(var, var_expected) # type: ignore[arg-type]

Expand Down
Loading