sparsemat / sprs

sparse linear algebra library for rust
Apache License 2.0
397 stars 47 forks source link

linfa-kernel v0.6.1 doesn't compile because of breaking change in 0.11.1 version #330

Closed clime closed 1 year ago

clime commented 1 year ago

Hello,

crate linfa-kernel v0.6.1 compiles with version 0.11.0 but no longer with 0.11.1.

error[E0599]: no method named `mul` found for reference `&CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>` in the current scope
  --> /home/clime/.cargo/registry/src/github.com-1ecc6299db9ec823/linfa-kernel-0.6.1/src/inner.rs:64:14
   |
64 |         self.mul(rhs)
   |              ^^^ method not found in `&CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>`

error[E0599]: no method named `mul` found for reference `&CsMatBase<F, usize, &'a [usize], &'a [usize], &'a [F]>` in the current scope
   --> /home/clime/.cargo/registry/src/github.com-1ecc6299db9ec823/linfa-kernel-0.6.1/src/inner.rs:109:14
    |
109 |         self.mul(rhs)
    |              ^^^ method not found in `&CsMatBase<F, usize, &'a [usize], &'a [usize], &'a [F]>

It happens in this piece of the code:

impl<F: Float> Inner for CsMat<F> {
    type Elem = F;

    fn dot(&self, rhs: &ArrayView2<F>) -> Array2<F> {
        self.mul(rhs)
    }

    ...
}

Has there been some change of the interface in the 0.11.1 version?

mulimoen commented 1 year ago

I away from a computer but I have an idea. Maybe one or both of them needs to be a view type? Try. .view() and see if that ccompiles

jlogan03 commented 1 year ago

I'll give this a look with cargo-semver-checks and see if it can pinpoint an unintended breaking change

jlogan03 commented 1 year ago

Here's the full output from cargo-semver-checks. The only breaking changes to the public API introduced between 0.11.0 and 0.11.1 were added enum variants that should have no effect here.

If we can pinpoint the origin of the problem here and it's not captured by cargo-semver-checks, I'll make a ticket on cargo-semver-checks to add a lint for it.

Jamess-MacBook-Pro:sprs jlogan$ cargo semver-checks --baseline-version 0.11.0
    Updating index
     Parsing sprs v0.11.1 (current)
     Parsing sprs v0.11.0 (baseline)
    Checking sprs v0.11.0 -> v0.11.1 (minor change)
   Completed [   0.113s] 39 checks; 38 passed, 1 failed, 6 unnecessary

--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-check/tree/v0.22.1/src/lints/enum_variant_added.ron

Failed in:
  variant IoError:MismatchedMatrixMarketRead in /Users/jlogan/git/sprs/sprs/src/io.rs:20
  variant NumKind:Pattern in /Users/jlogan/git/sprs/sprs/src/num_kinds.rs:32
       Final [   0.115s] semver requires new major version: 1 major and 0 minor checks failed
     Parsing sprs-ldl v0.10.0 (current)
     Parsing sprs-rand v0.4.0 (current)
     Parsing sprs_suitesparse_camd v0.3.0 (current)
     Parsing sprs_suitesparse_ldl v0.8.0 (current)
     Parsing sprs_suitesparse_umfpack v0.1.0 (current)
     Parsing suitesparse-src v0.1.0 (current)
     Parsing suitesparse_camd_sys v0.1.1 (current)
     Parsing suitesparse_ldl_sys v0.3.0 (current)
     Parsing suitesparse_umfpack_sys v0.1.0 (current)
Error: Version sprs-ldl of crate 0.11.0 not found in registry
jlogan03 commented 1 year ago

I pulled linfa main branch and I'm able to build both linfa itself and linfa-kernel with sprs 0.11.1 without error. Is this error occurring on a different branch, or maybe with a different version of rustc? I'm using rustc 1.70.0 here

Jamess-MacBook-Pro:linfa-kernel jlogan$ cargo build
  Downloaded ndarray-stats v0.5.1
  Downloaded noisy_float v0.2.0
  Downloaded kdtree v0.6.0
  Downloaded order-stat v0.1.3
  Downloaded 4 crates (90.4 KB) in 0.98s
   Compiling num-traits v0.2.15
   Compiling num-integer v0.1.45
   Compiling matrixmultiply v0.3.7
   Compiling syn v1.0.109
   Compiling indexmap v1.9.3
   Compiling either v1.8.1
   Compiling hashbrown v0.12.3
   Compiling itertools v0.10.5
   Compiling num-complex v0.4.3
   Compiling approx v0.4.0
   Compiling noisy_float v0.2.0
   Compiling ndarray v0.15.6
   Compiling kdtree v0.6.0
   Compiling order-stat v0.1.3
   Compiling thiserror-impl v1.0.25
   Compiling thiserror v1.0.25
   Compiling sprs v0.11.1
   Compiling ndarray-stats v0.5.1
   Compiling linfa v0.6.1 (/Users/jlogan/git/linfa)
   Compiling linfa-nn v0.6.1 (/Users/jlogan/git/linfa/algorithms/linfa-nn)
   Compiling linfa-kernel v0.6.1 (/Users/jlogan/git/linfa/algorithms/linfa-kernel)
    Finished dev [unoptimized + debuginfo] target(s) in 15.56s
Jamess-MacBook-Pro:linfa-kernel jlogan$ rustc --version
rustc 1.70.0 (90c541806 2023-05-31)
Jamess-MacBook-Pro:linfa-kernel jlogan$
jlogan03 commented 1 year ago

@clime , are you still seeing this issue?