-
Notifications
You must be signed in to change notification settings - Fork 183
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
Provide concatenate along other axes #104
Comments
This is what I came up with for now as a helper that seems to work: function concatenateAlong(axis, ...arrays) {
let lastAxis = arrays[0].shape.length - 1;
let axes = arrays[0].shape.map((_, i) => {
// swap the required axis with the last one
switch (i) {
case lastAxis:
return axis;
case axis:
return lastAxis;
default:
return i;
}
});
arrays = arrays.map(a => a.transpose(...axes));
let result = numjs.concatenate(...arrays);
return result.transpose(...axes);
} Does it look reasonable? Is it perhaps worth adding it to the library? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While README mentions that it's possible to achieve concatenation along various axes by using transposition, it's pretty hard to wrap my head around how to do that on multi-dimensional arrays. It would be a lot easier if such concatenation was part of the user-facing API, like it is in numpy.
Example code that I'm trying to convert right now:
Even if I manage to rewrite it using transpositions, I feel it won't be very readable / maintainable going forward.
The text was updated successfully, but these errors were encountered: