Skip to content

Commit 5e4e8c4

Browse files
authored
Added named_arrays.AbstractArray.var() method. (#107)
1 parent ccc07cc commit 5e4e8c4

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

named_arrays/_core.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,13 @@ def std(
817817
) -> Self:
818818
return np.std(self, axis=axis, where=where)
819819

820+
def var(
821+
self: Self,
822+
axis: None | str | Sequence[str] = None,
823+
where: Self = np._NoValue,
824+
) -> Self:
825+
return np.var(self, axis=axis, where=where)
826+
820827
def percentile(
821828
self: Self,
822829
q: int | float | u.Quantity | Self,

named_arrays/tests/test_core.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,12 @@ def test_std(
11961196
):
11971197
assert np.array_equal(array.std(), np.std(array))
11981198

1199+
def test_var(
1200+
self,
1201+
array: na.AbstractArray,
1202+
):
1203+
assert np.array_equal(array.var(), np.var(array))
1204+
11991205
def test_percentile(
12001206
self,
12011207
array: na.AbstractArray,

0 commit comments

Comments
 (0)