aldanor / hdf5-rust

HDF5 for Rust
https://docs.rs/hdf5
Apache License 2.0
310 stars 85 forks source link

If you specify the offline path of the ndarray crate in cargo.toml, the example code cannot be compiled. #263

Closed SilmaliTech closed 11 months ago

SilmaliTech commented 11 months ago

I tried combining many different versions of ndarray and hdf5 crates, but they all failed. The problem occurs when you try to use the ndarray crate offline. I tried them one by one while looking at the dependencies in crate.io. The result is all failure...

sequence of the work.

  1. cargo new aaaaaa -bin
  2. Define dependencies in cargo.toml
    ndarray = { version = "0.15.6"}
    hdf5 = { version = "0.8.1" }
    # There are no problems compiling the example code.
  3. Download ndarray 0.15.6 version from github and move to the project folder!
    ndarray = { path = "ext_library/ndarray-0.15.6", version = "0.15.6"}
    hdf5 = { version = "0.8.1" }
    # Compilation of example code is not possible.

    Error that occurs

    1

    the trait bound ndarray::ArrayBase<OwnedRepr<Pixel>, ndarray::Dim<[usize; 2]>>: AsRef<[_]> is not satisfied required for ndarray::ArrayBase<ndarray::ViewRepr<&_>, ndarray::dimension::dim::Dim<[usize; 1]>> to implement From<&ndarray::ArrayBase<OwnedRepr<Pixel>, ndarray::Dim<[usize; 2]>>> required for &ndarray::ArrayBase<OwnedRepr<Pixel>, ndarray::Dim<[usize; 2]>> to implement Into<ndarray::ArrayBase<ndarray::ViewRepr<&_>, ndarray::dimension::dim::Dim<[usize; 1]>>>

    2

    can't compare ndarray::ArrayBase<ndarray::data_repr::OwnedRepr<Pixel>, _> with ndarray::ArrayBase<OwnedRepr<Pixel>, ndarray::Dim<[usize; 2]>> the trait PartialEq<ndarray::ArrayBase<OwnedRepr<Pixel>, ndarray::Dim<[usize; 2]>>> is not implemented for ndarray::ArrayBase<ndarray::data_repr::OwnedRepr<Pixel>, _> the following other types implement trait PartialEq<Rhs>: <ndarray::ArrayBase<S, D> as PartialEq<ndarray::ArrayBase<S2, D>>> <ndarray::ArrayBase<S, D> as PartialEq<&'a ndarray::ArrayBase<S2, D>>> <&'a ndarray::ArrayBase<S, D> as PartialEq<ndarray::ArrayBase<S2, D>>>

    3

    the trait bound Selection: From<SliceInfo<[SliceInfoElem; 2], ndarray::Dim<[usize; 2]>, ndarray::Dim<[usize; 2]>>> is not satisfied the following other types implement trait From<T>: <Selection as From> <Selection as From<ndarray::ArrayBase<ndarray::data_repr::OwnedRepr, ndarray::dimension::dim::Dim<[usize; 1]>>>> <Selection as From<ndarray::ArrayBase<ndarray::data_repr::OwnedRepr, ndarray::dimension::dim::Dim<[usize; 2]>>>> <Selection as From<ndarray::ArrayBase<ndarray::ViewRepr<&usize>, ndarray::dimension::dim::Dim<[usize; 2]>>>> <Selection as From<ndarray::ArrayBase<ndarray::ViewRepr<&usize>, ndarray::dimension::dim::Dim<[usize; 1]>>>> <Selection as From> <Selection as From<_IMPL_H5TYPE_FOR_Color::_h5::Hyperslab>> <Selection as From<Vec>> and 25 others required for SliceInfo<[SliceInfoElem; 2], ndarray::Dim<[usize; 2]>, ndarray::Dim<[usize; 2]>> to implement Into<Selection> required for Selection to implement TryFrom<SliceInfo<[SliceInfoElem; 2], ndarray::Dim<[usize; 2]>, ndarray::Dim<[usize; 2]>>>

SilmaliTech commented 11 months ago

Here's some additional information that might be helpful. ubuntu 22.04 $sudo apt-get install libhdf5-dev $apt-cache policy libhdf5-dev libhdf5-dev: installed: 1.10.7+repack-4ubuntu2

mulimoen commented 11 months ago

You might find the information you are looking for here: https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html

The patch section should override ndarray in all dependencies

SilmaliTech commented 11 months ago

You might find the information you are looking for here: https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html

The patch section should override ndarray in all dependencies

thank you I've been trying to solve this problem for hours. I wouldn't have been able to solve it without you. I think I have something new to learn about Rust!!

mulimoen commented 11 months ago

No problem, feel free to post a new question if there is something specific you are trying to do with this crate