You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
This is what I came up with for now as a helper that seems to work:
functionconcatenateAlong(axis, ...arrays){letlastAxis=arrays[0].shape.length-1;letaxes=arrays[0].shape.map((_,i)=>{// swap the required axis with the last oneswitch(i){caselastAxis:
returnaxis;caseaxis:
returnlastAxis;default:
returni;}});arrays=arrays.map(a=>a.transpose(...axes));letresult=numjs.concatenate(...arrays);returnresult.transpose(...axes);}
Does it look reasonable? Is it perhaps worth adding it to the library?
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: