-
Notifications
You must be signed in to change notification settings - Fork 299
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
Add approx-0_5 feature for approx 0.5 support #1025
Conversation
`approx` 0.5 updates its `num-complex` dependency to 0.4, which is the same version of `num-complex` which `ndarray` depends on. So, it's very useful for `ndarray` to support `approx` 0.5.
I think a feature name like |
Okay, I've changed it to I guess the "p" thing is unique to me. When naming files/directories for the results of scientific code, I often have one more more parameters (which may not be integers) in the name. I generally avoid dots in filenames (except as the file extension delimiter), I use |
Could anyone elaborate on why the dependency on approx 0.4 has to be kept rather than just updating it to 0.5? It wasn't clear to me either in this PR or in #1024. |
Changing the version of the |
Do you mean a breaking change in terms of the version requirement? API-wise there is no breaking change between v0.4.0 vs. v0.5.0. |
Yes, the version numbers signal a breaking change. See Cargo's documentation for more information. Let's say a user had the following code: # Cargo.toml
[package]
name = "foo"
version = "0.1.0"
edition = "2018"
[dependencies]
approx = "0.4.0"
ndarray = { version = "0.15.3", features = ["approx"] } // src/main.rs
use approx::{assert_abs_diff_eq, AbsDiffEq};
use ndarray::{array, Array1};
#[derive(Debug, PartialEq)]
struct Wrapper(f64);
impl AbsDiffEq<Wrapper> for Wrapper {
type Epsilon = f64;
fn default_epsilon() -> f64 {
f64::default_epsilon()
}
fn abs_diff_eq(&self, other: &Wrapper, epsilon: f64) -> bool {
self.0.abs_diff_eq(&other.0, epsilon)
}
}
fn main() {
let a: Array1<Wrapper> = array![Wrapper(0.), Wrapper(1.)];
let b: Array1<Wrapper> = array![Wrapper(0.), Wrapper(1.)];
assert_abs_diff_eq!(a, b);
} Changing In other words, we can change change To clarify, |
I see. This makes sense. Thanks for the explanation. |
Approx is a public dependency - meaning we use their types/traits in our public API. So any update to "them" is an update to our API. |
We will add this, but this feature will also disappear as soon as ndarray 0.16 is released. |
Thanks! |
approx
0.5 updates itsnum-complex
dependency to 0.4, which is the same version ofnum-complex
whichndarray
depends on. So, it's very useful forndarray
to supportapprox
0.5.See also #1024, which attempts to support
approx
0.5 by changing the version range to">=0.4, <0.6"
. Unfortunately, that doesn't work.