Skip to content

feat: add ndarray/base/full#11017

Open
LoayAhmed304 wants to merge 4 commits intostdlib-js:developfrom
LoayAhmed304:feat/base-ndarray-full
Open

feat: add ndarray/base/full#11017
LoayAhmed304 wants to merge 4 commits intostdlib-js:developfrom
LoayAhmed304:feat/base-ndarray-full

Conversation

@LoayAhmed304
Copy link
Contributor

Resolves #{{TODO: add issue number}}.

Description

What is the purpose of this pull request?

This pull request:

  • Implements the full function for ndarrays, which creates an ndarray having a specified shape, data type, and filled with a specified value.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

  • #{{TODO: add related issue number}}

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.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

{{TODO: add disclosure if applicable}}


@stdlib-js/reviewers

@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Mar 18, 2026
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Mar 18, 2026

Coverage Report

Package Statements Branches Functions Lines
ndarray/base/full $\color{green}126/126$
$\color{green}+100.00%$
$\color{green}5/5$
$\color{green}+100.00%$
$\color{green}1/1$
$\color{green}+100.00%$
$\color{green}126/126$
$\color{green}+100.00%$

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

* var dt = String( getDType( arr ) );
* // returns 'float32'
*/
function full( dtype, shape, order, value ) {
Copy link
Member

Choose a reason for hiding this comment

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

Why does the argument order differ from other packages, such as ndarray/base/broadcast-scalar and ndarray/base/scalar2ndarray? Can you point to another example where we follow your proposed convention?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I based the argument order on empty and just appended the value argument at the end, but it would likely make more sense to put it at the beginning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. The argument order is now (value, dtype, shape, order). Since empty uses (dtype, shape, order), I prepended the value argument.

}

arr = empty( dtype, shape, order );
return fill( arr, value );
Copy link
Member

Choose a reason for hiding this comment

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

It is not clear why we are calling fill here which ends up doing various duplicated logic when we could simply inline the call to broadcastScalar and assign.

Copy link
Member

Choose a reason for hiding this comment

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

Doing it this way saves you a whole one line of code, which doesn't seem worth it to me, especially when we end up having to re-materialize the input ndarray dtype, shape, and order, which have been specified directly here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I left the same TODO comment from the fill function, regarding assign-scalar.

@kgryte kgryte added Feature Issue or pull request for adding a new feature. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. Needs Changes Pull request which needs changes before being merged. difficulty: 3 Likely to be challenging but manageable. and removed Needs Review A pull request which needs code review. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. labels Mar 18, 2026
@LoayAhmed304 LoayAhmed304 requested a review from kgryte March 18, 2026 21:42
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

difficulty: 3 Likely to be challenging but manageable. Feature Issue or pull request for adding a new feature. Needs Changes Pull request which needs changes before being merged. Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants