Unable to import traits implementation from ndarray

Open
#230 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
rust
Domain
api

Research direction

Start by reproducing the imports and least_squares call from Cargo.toml and chow.rs:19 with the stated ndarray and ndarray-linalg versions. Check the trait implementations and method signatures for the shown Array types; done means identifying whether the example is incompatible or correcting the documented usage and adding a regression test if appropriate.

Written by the indexing model from the issue text.

Description

question

Question

  • Hi I run in a problem related with LeastSquare: I am trying to import the ndarray_linalg:: {LeastSquaresSvd, LeastSquaresSvdInto, LeastSquaresSvdInPlace} . And calling from ndarray::Array1::least_squares class.
    • However the rust compiler unable to import it.

Cargo setup

  • The OS environment is running in WSL2 in windows 10
#Cargo.toml

...
[dependencies]
openblas-src = { version = "*", features = ["static"] }
ndarray = "0.12"
ndarray-linalg = { version = "0.12.0", features = ["openblas"] }
ndarray-stats = "0.3"
...
  • code snippets to
// mod.rs 
extern crate ndarray_linalg;
extern crate ndarray;
extern crate openblas_src;
pub mod foo.
...

// foo.rs
use ndarray
use ndarray_linalg::{LeastSquaresSvd, LeastSquaresSvdInto, LeastSquaresSvdInPlace};
let a= array![
            [1., 1., 1.],
            [2., 3., 4.],
            [3., 5., 2.],
            [4., 2., 5.],
            [5., 4., 3.]
        ];
 // solving for a single right-hand 
let b = array![-10., 12., 14., 16., 18.];
// let res = a.least_squares(&b);

// using `least_squares_in_place` which overwrites its arguments
// let mut a_3 = a.clone();
// let mut b_3 = b.clone();
let (m, n) = (a.shape()[0], a.shape()[1]);
let solution = b.slice(s![0..n]).to_owned();
let result = a.least_squares(&b); // unable to find  least_squares 
...
  • The error outputs
  --> keyboard-analyzer/src/models/structural_break_analysis/chow.rs:19:22
   |
19 | use ndarray_linalg::{LeastSquaresSvd, LeastSquaresSvdInto, LeastSquaresSvdInPlace};
 ....

method not found in `ndarray::ArrayBase<models::structural_break_analysis::ndarray::OwnedRepr<{float}>, 
   models::structural_break_analysis::ndarray::Dim<[usize; 2]>>`
Dominant language
Rust
Stars
452
Forks
95
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-ndarray/ndarray-linalg

All issues in rust-ndarray/ndarray-linalg

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.