add std as method (#1387)

* add std as method

* add std as method
This commit is contained in:
Awni Hannun 2024-09-01 19:49:16 -07:00 committed by GitHub
parent 58dca7d846
commit 9592766939
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 1 deletions

View File

@ -53,8 +53,9 @@ Array
array.sqrt
array.square
array.squeeze
array.swapaxes
array.std
array.sum
array.swapaxes
array.transpose
array.T
array.var

View File

@ -78,6 +78,7 @@ Operations
hadamard_transform
identity
inner
isfinite
isclose
isinf
isnan

View File

@ -1115,6 +1115,22 @@ void init_array(nb::module_& m) {
nb::kw_only(),
"stream"_a = nb::none(),
"See :func:`mean`.")
.def(
"std",
[](const array& a,
const IntOrVec& axis,
bool keepdims,
int ddof,
StreamOrDevice s) {
return mlx::core::std(
a, get_reduce_axes(axis, a.ndim()), keepdims, ddof, s);
},
"axis"_a = nb::none(),
"keepdims"_a = false,
"ddof"_a = 0,
nb::kw_only(),
"stream"_a = nb::none(),
"See :func:`std`.")
.def(
"var",
[](const array& a,