8000 Added implementation of `var` and `std` methods for ArrayBase by kdubovikov · Pull Request #790 · rust-ndarray/ndarray · GitHub
[go: up one dir, main page]

Skip to content

Added implementation of var and std methods for ArrayBase #790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fixed formatting errors
  • Loading branch information
Kirill Dubovikov authored and bluss committed Jan 7, 2021
commit 0e292f05f72a8b48a8621f8f97801d6ae0e2d1b7
5 changes: 2 additions & 3 deletions src/numeric/impl_numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ where
/// ```
pub fn var(&self, ddof: A) -> A
where
A: Float + FromPrimitive
8000 A: Float + FromPrimitive,
{
let zero = A::from_usize(0).expect("Converting 0 to `A` must not fail.");
let n = A::from_usize(self.len()).expect("Converting length to `A` must not fail.");
Expand Down Expand Up @@ -216,12 +216,11 @@ where
/// ```
pub fn std(&self, ddof: A) -> A
where
A: Float + FromPrimitive
A: Float + FromPrimitive,
{
self.var(ddof).sqrt()
}


/// Return sum along `axis`.
///
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ macro_rules! private_impl {
fn __private__(&self) -> crate::private::PrivateMarker {
crate::private::PrivateMarker
}
}
};
}
2 changes: 0 additions & 2 deletions tests/numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ fn sum_mean_empty() {
fn var() {
let a = array![1., -4.32, 1.14, 0.32];
assert_abs_diff_eq!(a.var(0.), 5.049875, epsilon = 1e-8);

}

#[test]
Expand Down Expand Up @@ -102,7 +101,6 @@ fn var_empty_arr() {
fn std() {
let a = array![1., -4.32, 1.14, 0.32];
assert_abs_diff_eq!(a.std(0.), 2.24719, epsilon = 1e-5);

}

#[test]
Expand Down
0