Skip to content

feat: add missing tests to ndarray/base/every-by #7285

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
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

headlessNode
Copy link
Member


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: na
  • task: lint_package_json status: na
  • task: lint_repl_help status: na
  • task: lint_javascript_src status: na
  • task: lint_javascript_cli status: na
  • task: lint_javascript_examples status: na
  • task: lint_javascript_tests status: passed
  • 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: na
  • task: lint_typescript_tests status: na
  • task: lint_license_headers status: passed ---

Progresses #2656 .

Description

What is the purpose of this pull request?

This pull request:

  • add tests for 100% test code coverage

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

---
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: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@headlessNode headlessNode added Tests Pull requests specifically adding tests. GSoC Google Summer of Code. gsoc: 2025 Google Summer of Code (2025). labels Jun 9, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jun 9, 2025

Coverage Report

Package Statements Branches Functions Lines
ndarray/base/every-by $\color{red}4286/8573$
$\color{green}+49.99\%$
$\color{red}112/114$
$\color{green}+98.25\%$
$\color{red}9/43$
$\color{green}+20.93\%$
$\color{red}4286/8573$
$\color{green}+49.99\%$

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

Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
---
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: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
---
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: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
function clbk( v ) {
return ( real( v ) !== 0.0 && imag( v ) !== 0.0 );
}
});
Copy link
Member

@kgryte kgryte Jun 11, 2025

Choose a reason for hiding this comment

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

I suggest adding four tests here, all of which should be testing that the function supports providing a callback execution context. I say four tests, as you want one for indexed arrays and another for accessor arrays in both row and column-major orders.

In those tests, you should cache provided callback arguments and test that provided arguments match expectation. In particular, that the sequence of values is correct, that the sequence of indices is correct, and that the array is provided on each call.

For reference, see also

tape( 'the function supports specifying the callback execution context (row-major)', function test( t ) {
where this sort of testing is performed.

dt = 'complex128';
ord = 'column-major';
sh = [ 2, 2 ];
st = [ 4, -1 ];
Copy link
Member

Choose a reason for hiding this comment

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

The strides are incorrect here.

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 check your other similar PRs, as well, as I imagine this has been copy-pasted elsewhere.

Copy link
Member

Choose a reason for hiding this comment

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

If this came from an existing set of tests, we should fix in those tests, as well.

function clbk( v ) {
return ( real( v ) !== 0.0 && imag( v ) !== 0.0 );
}
});
Copy link
Member

@kgryte kgryte Jun 11, 2025

Choose a reason for hiding this comment

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

Same comment regarding testing that providing an execution context is supported. Only test on contiguous arrays (e.g., 2x2 with strides (2,1) ). Don't worry about large non-contiguous arrays, as testing these is trickier due to blocked iteration patterns.

Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

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

Overall, these tests look good. Main comment concerns ensuring that we support providing a callback execution context and ensuring that the callback is provided the correct arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GSoC Google Summer of Code. gsoc: 2025 Google Summer of Code (2025). Tests Pull requests specifically adding tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants