Skip to content

Conversation

@kaushal-kumar-it
Copy link
Contributor


type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:

  • task: lint_filenames status: passed
  • task: lint_editorconfig status: passed
  • task: lint_markdown status: passed
  • task: lint_package_json status: na
  • task: lint_repl_help status: passed
  • task: lint_javascript_src status: passed
  • task: lint_javascript_cli status: na
  • task: lint_javascript_examples status: passed
  • task: lint_javascript_tests status: na
  • task: lint_javascript_benchmarks status: na
  • task: lint_python status: na
  • task: lint_r status: na
  • task: lint_c_src status: na
  • task: lint_c_examples status: na
  • task: lint_c_benchmarks status: na
  • task: lint_c_tests_fixtures status: na
  • task: lint_shell status: na
  • task: lint_typescript_declarations status: passed
  • task: lint_typescript_tests status: passed
  • task: lint_license_headers status: passed ---

Progresses #9329.

Description

This pull request updates documentation examples in the @stdlib/ndarray/some-by package to improve doctests for ndarray instances, in accordance with the RFC guidance.

Specifically, this PR:

  • Replaces explicit ndarray element access and decomposition logic with ndarray instance return notation (e.g., <ndarray>[ ... ])
  • Updates examples to supply predicate functions where required so doctests execute successfully
  • Removes no-longer-needed decomposition code while preserving the original example behavior and intent
  • Makes changes only within this package, without altering example semantics or introducing unrelated modifications

These updates improve clarity, consistency, and alignment with recent doctest framework capabilities.

Related Issues

Questions

No.

Other

No additional information.

Checklist

AI Assistance

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

  • Yes
  • No

@stdlib-js/reviewers

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: passed
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: passed
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: passed
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. Good First PR A pull request resolving a Good First Issue. labels Dec 28, 2025
@stdlib-bot
Copy link
Contributor

Hello! 👋

We've noticed that you've been opening a number of PRs addressing good first issues. Thank you for your interest and enthusiasm!

Now that you've made a few contributions, we suggest no longer working on good first issues. Instead, we encourage you to prioritize cleaning up any PRs which have yet to be merged and then proceed to work on more involved tasks.

Not only does this ensure that other new contributors can work on things and get ramped up on all things stdlib, it also ensures that you can spend your time on more challenging problems. 🚀

For ideas for future PRs, feel free to search the codebase for TODOs and FIXMEs and be sure to check out other open issues on the issue tracker. Cheers!

@stdlib-bot
Copy link
Contributor

Coverage Report

Package Statements Branches Functions Lines
ndarray/some-by $\color{green}592/592$
$\color{green}+100.00%$
$\color{green}80/80$
$\color{green}+100.00%$
$\color{green}3/3$
$\color{green}+100.00%$
$\color{green}592/592$
$\color{green}+100.00%$

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR! I don’t think we need to update anything in index.js here, right @kgryte ?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, no need to update the examples/index.js. Usage of ndarray2array and y.get() is correct here.


// Perform reduction:
var out = someBy.assign( x, 2, y, predicate );
// returns <ndarray>
Copy link
Contributor

Choose a reason for hiding this comment

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

include [ true ] here


// Perform reduction:
var out = someBy.assign( x, 2, y, opts, predicate );

Copy link
Contributor

Choose a reason for hiding this comment

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

return is missing here

Copy link
Member

@headlessNode headlessNode left a comment

Choose a reason for hiding this comment

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

@Lokeshranjan8 Left initial comments.

Comment on lines -101 to -102
> var bool = ( out === y )
true
Copy link
Member

Choose a reason for hiding this comment

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

No need to remove these lines. Also, you can go ahead and add this to the examples of the assign method in other files.

var bool = ( out === y );
// returns true

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, no need to update the examples/index.js. Usage of ndarray2array and y.get() is correct here.

Comment on lines 242 to 261
```javascript
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
var isEven = require( '@stdlib/assert/is-even' ).isPrimitive;
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
var fillBy = require( '@stdlib/ndarray/fill-by' );
var zeros = require( '@stdlib/ndarray/zeros' );
var someBy = require( '@stdlib/ndarray/some-by' );

var x = zeros( [ 2, 4, 5 ], {
'dtype': 'float64'
});
x = fillBy( x, discreteUniform( 0, 10 ) );
console.log( ndarray2array( x ) );
console.log( x );

var n = scalar2ndarray( 4, {
'dtype': 'int8'
});
var y = someBy( x, n, isEven );
console.log( y.get() );
console.log( y );
```
Copy link
Member

Choose a reason for hiding this comment

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

No need to remove the use of ndarray2array and y.get() from here.

@kgryte kgryte added Documentation Improvements, additions, or changes to documentation. Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements, additions, or changes to documentation. Good First PR A pull request resolving a Good First Issue. Needs Changes Pull request which needs changes before being merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants