to266 / optimize

Rust crate for numerical optimization
Apache License 2.0
7 stars 3 forks source link

Not compatible to ndarray 0.12.0 #1

Open astrojhgu opened 6 years ago

astrojhgu commented 6 years ago

when using with ndarray 0.12 following error raises, and switching to 0.11 makes it work

    = note: expected type `ndarray::ArrayBase<ndarray::ViewRepr<&f64>, ndarray::dimension::dim::Dim<[usize; 1]>>`
               found type `ndarray::ArrayBase<ndarray::ViewRepr<&f64>, ndarray::Dim<[usize; 1]>>`
to266 commented 6 years ago

Hi there!

Thanks for reporting the issue. Could you give a minimal example that exhibits the behaviour? I'm not able to reproduce.

astrojhgu commented 6 years ago

Hi, I place a test code at this respository.

I compile the code with rustc 1.32.0-nightly (8b096314a 2018-11-02).

If you set the ndarray version to 0.11.0, then it compiles, if you change it to 0.12.0, following error message appears: ` error[E0308]: mismatched types --> src/main.rs:21:9 21 Array1::::from_vec(vec![100.0,100.0]).view() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct ndarray::ArrayBase, found a different struct ndarray::ArrayBase

= note: expected type ndarray::ArrayBase<ndarray::ViewRepr<&f64>, ndarray::dimension::dim::Dim<[usize; 1]>> found type ndarray::ArrayBase<ndarray::ViewRepr<&f64>, ndarray::Dim<[usize; 1]>> note: Perhaps two different versions of crate ndarray are being used? --> src/main.rs:21:9 | 21 | Array1::::from_vec(vec![100.0,100.0]).view() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0631]: type mismatch in closure arguments --> src/main.rs:17:28 | 17 | let result = minimizer.minimize( | ^^^^^^^^ expected signature of for<'r> fn(ndarray::ArrayBase<ndarray::ViewRepr<&'r f64>, ndarray::dimension::dim::Dim<[usize; 1]>>) -> _ 18 | move |x: ArrayView1| { | ------------------------- found signature of for<'r> fn(ndarray::ArrayBase<ndarray::ViewRepr<&'r f64>, ndarray::Dim<[usize; 1]>>) -> _

error: aborting due to 2 previous errors

Some errors occurred: E0308, E0631. For more information about an error, try rustc --explain E0308. error: Could not compile opt_test.

To learn more, run the command again with --verbose. `

astrojhgu commented 6 years ago

Actually, I find that simply change ndarray version from 0.11 to 0.12 can solve this problem.

However, I noticed the structure of this crate has been changed: Minimizer seems to be removed and Builer moved from root to vector.