0

I'm using ndarray and ndarray_einsum_beta to mimic numpy.einsum.

I seem to be getting a type error trying to implement the basic example given:

let m1 = arr1(&[1, 2]);
let m2 = arr2(&[[1, 2], [3, 4]]);
println!("{:?}", einsum("i,ij->j", &[&m1, &m2]));

For both m1 and m2 I get the error:

the trait bound ndarray::ArrayBase<ndarray::OwnedRepr<{integer}>, ndarray::Dim<[usize; 1]>>: ndarray_einsum_beta::ArrayLike<_> is not satisfied

the trait ndarray_einsum_beta::ArrayLike<_> is not implemented for ndarray::ArrayBase<ndarray::OwnedRepr<{integer}>, ndarray::Dim<[usize; 1]>>

note: required for the cast to the object type dyn ndarray_einsum_beta::ArrayLike<_>rustc(E0277)

As shown in the console on compilcation:enter image description here

Whole main.rs:

use ndarray::prelude::*;
use ndarray_einsum_beta::*;

fn main() {
    println!("Hello, world!");
    let m1 = arr1(&[1, 2]);
    let m2 = arr2(&[[1, 2], [3, 4]]);
    println!("{:?}", einsum("i,ij->j", &[&m1, &m2]));
}

Whole Cargo.toml:

[package]
name = "clean_slate"
version = "0.1.0"
authors = ["Jonathan <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ndarray = "0.13.0"
ndarray_einsum_beta = "0.4.4"

I really cannot figure what I have done wrong here, my best guess right now is perhaps a bad version combination of ndarray and ndarray_eisum_beta.

Any help would be greatly appreciated.

1 Answer 1

1

Apparently ndarray_einsum_beta depends on ndarray-0.12. Changing the dependencies of your project solves the problem:

[dependencies]
ndarray = "0.12"
ndarray_einsum_beta = "0.4.4"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.