-
Notifications
You must be signed in to change notification settings - Fork 9
fix: Add display trait to functions in spindalis_core #61
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
Conversation
|
For the display of the polynomials, I was thinking more along the lines of I like the idea of, for example, the let dx = simple_derivative(&parsed);
println!("Derivative coefficients: {dx:?}"); let dx = simple_derivative(&parsed).coefficients;
println!("Derivative coefficients: {dx:?}");I'd prefer that Optimally, the function would look something like this after the display trait is added let dx = simple_derivative(&parsed);
println!("Derivative coefficients: {dx}");That's also the case for the following functions that I can find (I might miss some)
|
|
The display trait is now like what I had in mind! I see that the simple polynomial example was fixed, but what about the others like this in polynomial extended example: // Calculative partial derivative
println!("Partial derivatives of polynomials");
let dx = partial_derivative(&parsed, "x").terms; <-
println!("Derivative with respect to x: {dx:?}");
let dy = partial_derivative(&parsed, "y").terms; <-
println!("Derivative with respect to y: {dy:?}");
let dz = partial_derivative(&parsed, "z".to_string()).terms; <-
println!("Derivative with respect to z: {dz:?}");And #[test]
fn test_derivative_linear() {
let poly = vec![2.0, 3.0]; // 2 + 3x
let deriv = simple_derivative(&poly).coefficients;
assert_eq!(deriv, vec![3.0]); // simple_derivative: 3
}it would look like this #[test]
fn test_derivative_linear() {
let poly = vec![2.0, 3.0]; // 2 + 3x
let deriv = simple_derivative(&poly);
assert_eq!(deriv, vec![3.0]); // simple_derivative: 3
}With the same being true for the polynomial extended tests. Also, I just noticed that your commits don't have your username associated with them, so you might need to fix your git settings so that you'll be added as a contributor when these changes are merged |
|
@mahmudsudo Hopefully you should just be able to add that trait and everything will work as expected, especially because I see that you already added it to the |
|
Funniest thing was I added it before pushing and edited it away when there was a merge conflict on the branch |
|
Check the other pr, so we can get both merged in time |
|
Everything looks good here! I'll merge this a little bit later this afternoon when I'll have time to give it a final once over |
closes #43