Skip to content

Commit

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

def median(
self,
axis: None | str | Sequence[str] = None,
):
return np.median(self, axis=axis)

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 @@ -1202,6 +1202,12 @@ def test_var(
):
assert np.array_equal(array.var(), np.var(array))

def test_median(
self,
array: na.AbstractArray,
):
assert np.array_equal(array.median(), np.median(array))

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

0 comments on commit 2b0d02b

Please sign in to comment.