Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add ndarray/concat #7969

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

Draft
headlessNode wants to merge 2 commits into stdlib-js:develop
base: develop
Choose a base branch
Loading
from headlessNode:ndarray-concat

Conversation

Copy link
Member

@headlessNode headlessNode commented Aug 25, 2025

Progresses #2656.

Description

What is the purpose of this pull request?

This pull request:

  • add ndarray/concat

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

@headlessNode headlessNode added Feature Issue or pull request for adding a new feature. GSoC Google Summer of Code. gsoc: 2025 Google Summer of Code (2025). labels Aug 25, 2025
Copy link
Member Author

Need to merge #7853 first.

* Concatenates a list of ndarrays along a specified ndarray dimension.
*
* @param {ArrayLikeObject<Object>} arrays - array-like object containing input ndarrays
* @param {integer} dim - dimension along which the arrays are concatenated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a negative integer and should be validated as such.

N = arrays.length;
arrs = [];
if ( N < 1 ) {
throw new RangeError( format( 'invalid argument. First argument must have more than one ndarray. Value: `%s`.', N ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new RangeError( format( 'invalid argument. First argument must have more than one ndarray. Value: `%s`.', N ) );
throw new RangeError( format( 'invalid argument. First argument must have one or more ndarrays. Value: `%s`.', N ) );

* @param {ArrayLikeObject<Object>} arrays - array-like object containing input ndarrays
* @param {integer} dim - dimension along which the arrays are concatenated
* @throws {TypeError} first argument must be an array of ndarray-like objects
* @throws {RangeError} first argument must have more than one ndarray
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs updating.

orders = [];
for ( i = 0; i < N; i++ ) {
if ( !isndarrayLike( arrays[ i ] ) ) {
throw new TypeError( format( 'invalid argument. First argument must be an array of ndarray-like objects. Value: `%s`.', arrays[ i ] ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new TypeError( format( 'invalid argument. First argument must be an array of ndarray-like objects. Value: `%s`.', arrays[ i ] ) );
throw new TypeError( format( 'invalid argument. First argument must be an array of ndarrays. Value: `%s`.', arrays[ i ] ) );

throw new RangeError( format( 'invalid argument. Output ndarray must have %d dimensions. Value: %d.', sh.length, getShape( out ).length ) );
}
for ( i = 0; i < sh.length; i++ ) {
if ( getShape( out )[ i ] !== sh[ i ] ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not be calling getShape repeatedly like this. You're materializing a new shape array for every call.

if ( getDtype( out ) !== dt ) {
throw new TypeError( format( 'invalid argument. Output ndarray must have a dtype of `%s`. Value: `%s`.', dt, getDtype( out ) ) );
}
if ( getOrder( out ) !== ord ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it necessary for the output array to have the resolved order?

}
ord = resolveOutputOrder( orders );
if ( out ) {
if ( getDtype( out ) !== dt ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it necessary for the output array to have the promoted data type?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about mostly safe casts?

Copy link
Member

kgryte commented Sep 7, 2025

/stdlib merge

stdlib-bot reacted with eyes emoji

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Sep 7, 2025
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Sep 7, 2025
Copy link
Contributor

Coverage Report

Package Statements Branches Functions Lines
ndarray/concat $\color{red}271/467$
$\color{green}+58.03\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{red}0/4$
$\color{green}+0.00\%$
$\color{red}271/467$
$\color{green}+58.03\%$

The above coverage report was generated for the changes in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@kgryte kgryte kgryte left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
Feature Issue or pull request for adding a new feature. GSoC Google Summer of Code. gsoc: 2025 Google Summer of Code (2025).
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /