Skip to content

Commit

Permalink
Added named_arrays.AbstractArray.var() method. (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
byrdie authored Feb 18, 2025
1 parent ccc07cc commit 5e4e8c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions named_arrays/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,13 @@ def std(
) -> Self:
return np.std(self, axis=axis, where=where)

def var(
self: Self,
axis: None | str | Sequence[str] = None,
where: Self = np._NoValue,
) -> Self:
return np.var(self, axis=axis, where=where)

def percentile(
self: Self,
q: int | float | u.Quantity | Self,
Expand Down
6 changes: 6 additions & 0 deletions named_arrays/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,12 @@ def test_std(
):
assert np.array_equal(array.std(), np.std(array))

def test_var(
self,
array: na.AbstractArray,
):
assert np.array_equal(array.var(), np.var(array))

def test_percentile(
self,
array: na.AbstractArray,
Expand Down

0 comments on commit 5e4e8c4

Please sign in to comment.