Questions tagged [rust-ndarray]

54 questions
0
votes
0 answers

Fastest way to convert stack image to grayscale

I am very new to rust coming from Python and some of the concepts and ways to play with the arrays are still very obscure for me. So as an initial exercise I tried to simply open a DICOM stack of images and convert them to grayscale. I came up with…
Unic0
  • 341
  • 1
  • 3
  • 19
0
votes
1 answer

How to create a PyArray to feed into method

I have a method foo with the following signature: pub fn foo(data: PyReadonlyArrayDyn) { ... } In my test I'm trying to create a test array to feed into foo pyo3::Python::with_gil(|py| { let vec = vec![1.0, 2.0, 3.0, 4.0]; py_array…
grmmgrmm
  • 994
  • 10
  • 29
0
votes
1 answer

How to get a zero Array2 copying dimension from another Array2

Just learning some rust. I'm using ndarray and I need to construct a zero matrix copying the dimension from another matrix. I tried fn make_0(matrix: Array2) -> Array2 { Array2::zeros(matrix.shape()) } But this does not…
matiasg
  • 1,927
  • 2
  • 24
  • 37
0
votes
1 answer

Rust ndarray slicing

I am using ndarray and trying to slice some arrays. This works let y = arr2(&[[ 6, 5, 4], [12, 11, 10]]); let ip = y.slice(s![0, ..]); println!("IP {}", ip); but this let y = arr2(&[[ 6, 5, 4], …
Codey McCodeface
  • 2,988
  • 6
  • 30
  • 55
0
votes
1 answer

Splitting a Vec of strings into Vec>

I am attempting to relearn data-science in rust. I have a Vec that includes a delimiter "|" and a new line "!end". What I'd like to end up with is Vec> that can be put into a 2D ND array. I have this python Code: file =…
TrapLordOb
  • 25
  • 4
0
votes
1 answer

How to add an integer to a slice from Rust ndarray?

Let me try: let mut a: Array2 = Array2::zeros((20, 20)); let z = a.slice(s![.., 1]); z += 1; which gives: error[E0368]: binary assignment operation `+=` cannot be applied to type `ArrayBase, _>`
Alper
  • 3,424
  • 4
  • 39
  • 45
0
votes
1 answer

Trait bound not satisfied building an ndarray from a tuple trait

I am very new to Rust. Currently, I am looking for a way to generate a matrix with dimension based on a tuple. use itertools::zip; use ndarray::Array; fn main() { let mut layer_width: [u64; 4] = [784, 512, 256, 10]; //in- & output layers of the…
Denny Rommel
  • 33
  • 1
  • 5
0
votes
1 answer

Making a method generic over Array1

I have the following Trait implementation and would like to make unit generic over Array1, but fail to find the right Trait bounds (especially that this somehow seems trivial to me, all T needs to support is basically basic arithmetic that output…
zareami10
  • 111
  • 7
-1
votes
1 answer

Associated type for ndarray arguments in rust

I want to create an interface for a (numeric) algorithm for which I want to provide an implementation with ndarray and similar libraries (let's say pytorch bindings) struct A { array: D } trait T { type ArgType; fn foo(&mut self,…
Stefan
  • 1
  • 2
1 2 3
4