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

Stack and concatenate #844

Merged
merged 7 commits into from
Oct 23, 2020
Merged

Stack and concatenate #844

merged 7 commits into from
Oct 23, 2020

Conversation

andrei-papou
Copy link
Contributor

Issue: #667

Continuation of #735 with the commit history being cleaned up.

Changes:

  • added concatenate proxy function to stack function, concatenate! proxy macro to stack! macro
  • deprecated stack function and stack! macro since 0.13.2
  • added stack_new_axis function and stack_new_axis! macro to mimic the behavior of np.stack function from numpy

In 0.14.0 we should probably rename stack_new_axis to stack and drop old stack function, same about macro.

concatenate
use ndarray::{arr2, Axis, concatenate};

let a = arr2(&[[2., 2.], [3., 3.]]);
assert!(
     concatenate(Axis(0), &[a.view(), a.view()])
     == Ok(arr2(&[[2., 2.], [3., 3.], [2., 2.], [3., 3.]]))
);
stack_new_axis
use ndarray::{arr2, arr3, stack_new_axis, Axis};

let a = arr2(&[[2., 2.],
               [3., 3.]]);
assert!(
    stack_new_axis![Axis(0), a, a]
    == arr3(&[[[2., 2.],
               [3., 3.]],
              [[2., 2.],
               [3., 3.]]])
);

@xd009642 xd009642 mentioned this pull request Oct 8, 2020
@bluss
Copy link
Member

bluss commented Oct 23, 2020

Thanks! Finally merging :)

@bluss bluss merged commit e808e2b into rust-ndarray:master Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants