Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example for an equivalent of numpy's column_stack function in ndarray_for_numpy_users #650

Open
synasius opened this issue Jun 30, 2019 · 0 comments

Comments

@synasius
Copy link

@synasius synasius commented Jun 30, 2019

I was looking for an equivalent function of numpy's column_stack (see https://docs.scipy.org/doc/numpy/reference/generated/numpy.column_stack.html) in ndarray docs.

This is how I managed to solve the issue:

use ndarray::{Array, Axis, stack, arr2};

let a = Array::linspace(0., 1., 5).into_shape((5,1)).unwrap();
let b = Array::<f64, _>::ones((5, 1));
let res = stack(Axis(1), &[b.view(), a.view()]);
assert!(res == Ok(arr2(&[[1., 0.],
                 [1., 0.25],
                 [1., 0.5],
                 [1., 0.75],
                 [1., 1.]])));

It could be worth to have an example in ndarray_for_numpy_users section of the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.