Skip to content
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

linalg and stats are incompatible with ndarray 0.16.0 #1425

Closed
ivan-aksamentov opened this issue Aug 20, 2024 · 7 comments
Closed

linalg and stats are incompatible with ndarray 0.16.0 #1425

ivan-aksamentov opened this issue Aug 20, 2024 · 7 comments

Comments

@ivan-aksamentov
Copy link

ivan-aksamentov commented Aug 20, 2024

Just linking the issues from the other repos for visibility:

This could be due to version mismatch in the dependencies.

Numerous third-party dependencies are also broken.

Things like .inv() (from linalg) and .argmax() from stats are essential for many applications. So, without these packages working it is not possible to take advantage of the improvements of ndarray 0.16, no matter how good they are.

I believe that before releasing new versons of ndarray maintainers should take care that at least the packages in the same organization work correctly.

I'd also consider to move the packages into a single workspace. This way it's easier to spot problems and to maintain them.

@bluss bluss changed the title linalg and stats are broken after 0.16.0 linalg and stats are incompatible with ndarray 0.16.0 Aug 20, 2024
@bluss
Copy link
Member

bluss commented Aug 20, 2024

Hi, do you have an example of them breaking? They should still work if keeping the versions constant, i.e. using ndarray 0.15 until the relevant crates have been updated.

@bluss
Copy link
Member

bluss commented Aug 25, 2024

Ndarray-stats is owned by the ndarray release team, so I could make releases there. For ndarray-linalg we need to involve the crate owners that can make a release.

@VlaDexa
Copy link

VlaDexa commented Aug 29, 2024

Hi, do you have an example of them breaking?

Example from ndarray_linalg docs no longer works.

use approx::AbsDiffEq; // for abs_diff_eq
use ndarray::{array, Array1, Array2};
use ndarray_linalg::{LeastSquaresSvd, LeastSquaresSvdInto, LeastSquaresSvdInPlace};

let a: Array2<f64> = array![
    [1., 1., 1.],
    [2., 3., 4.],
    [3., 5., 2.],
    [4., 2., 5.],
    [5., 4., 3.]
];
// solving for a single right-hand side
let b: Array1<f64> = array![-10., 12., 14., 16., 18.];
let expected: Array1<f64> = array![2., 1., 1.];
let result = a.least_squares(&b).unwrap();
assert!(result.solution.abs_diff_eq(&expected, 1e-12));

// solving for two right-hand sides at once
let b_2: Array2<f64> =
    array![[-10., -3.], [12., 14.], [14., 12.], [16., 16.], [18., 16.]];
let expected_2: Array2<f64> = array![[2., 1.], [1., 1.], [1., 2.]];
let result_2 = a.least_squares(&b_2).unwrap();
assert!(result_2.solution.abs_diff_eq(&expected_2, 1e-12));

// using `least_squares_in_place` which overwrites its arguments
let mut a_3 = a.clone();
let mut b_3 = b.clone();
let result_3 = a_3.least_squares_in_place(&mut b_3).unwrap();

// using `least_squares_into` which consumes its arguments
let result_4 = a.least_squares_into(b).unwrap();
// `a` and `b` have been moved, no longer valid

@bluss
Copy link
Member

bluss commented Aug 31, 2024

@VlaDexa I mean for examples, existing projects that stopped compiling or were broken by ndarray 0.16. That would be interesting. Any example requires a Cargo.toml or dependency information to be reproducible.

@aristaeus
Copy link

aristaeus commented Sep 2, 2024

I don't have a public example, but in a private project that updated to ndarray 0.16, all our linear algebra code broke because the ndarray 0.16 types don't implement the traits in ndarray-linalg. This was an especially confusing error to encounter because ndarray-linalg's version number is already 0.16, implying API compatibility. Of course, nothing is broken if we stay on 0.15.

@VlaDexa
Copy link

VlaDexa commented Sep 2, 2024

existing projects that stopped compiling or were broken by ndarray 0.16

My project was broken by ndarray 0.16. When I tried to update to the new version it stopped compiling because of incompatible structs.

Any example requires a Cargo.toml or dependency information to be reproducible.

Three crates from the first three lines of my somewhat minimal example are all the dependencies you need. I don't know how you guys do stuff around here, but I was taught that a minimal example would be better than saying "oh my project doesn't work now"

@bluss
Copy link
Member

bluss commented Sep 2, 2024

Ok, that's the line.

I've been the person who has been reaching out across the team to try to get this to work, we solved one of the crates.
This is a bug in ndarray-linalg and not a problem in this crate. As noted by user stories above, projects continue to work unless updates are attempted (and updates will work when the issue is resolved).

Please refer to the upstream downstream issue rust-ndarray/ndarray-linalg#380

@bluss bluss closed this as not planned Won't fix, can't repro, duplicate, stale Sep 2, 2024
@rust-ndarray rust-ndarray locked and limited conversation to collaborators Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants