Skip to content

Conversation

anandkaranubc
Copy link
Contributor

Resolves none.

Description

What is the purpose of this pull request?

This pull request:

  • Refactors random number generation in JS benchmarks for the remaining math/base/special/tan* packages
  • Replaces randu() with uniform() from @stdlib/random/array/uniform for cleaner and more consistent code.
  • Moves the random number generation outside the benchmarking loops.
  • Updates the test messages to follow code conventions.

Related Issues

Does this pull request have any related issues?

This pull request:

  • resolves none

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: passed
  - 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: passed
  - 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
---

---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
  - task: run_javascript_examples
    status: na
  - task: run_c_examples
    status: na
  - task: run_cpp_examples
    status: na
  - task: run_javascript_readme_examples
    status: na
  - task: run_c_benchmarks
    status: na
  - task: run_cpp_benchmarks
    status: na
  - task: run_fortran_benchmarks
    status: na
  - task: run_javascript_benchmarks
    status: na
  - task: run_julia_benchmarks
    status: na
  - task: run_python_benchmarks
    status: na
  - task: run_r_benchmarks
    status: na
  - task: run_javascript_tests
    status: na
---
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. labels Mar 1, 2025
@stdlib-bot
Copy link
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/tan $\color{green}229/229$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}229/229$
$\color{green}+100.00\%$
math/base/special/tand $\color{green}183/183$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}183/183$
$\color{green}+100.00\%$
math/base/special/tanh $\color{red}297/298$
$\color{green}+99.66\%$
$\color{red}23/24$
$\color{green}+95.83\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{red}297/298$
$\color{green}+99.66\%$

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

Copy link
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

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

LGTM!

@Planeshifter Planeshifter added the Ready To Merge A pull request which is ready to be merged. label Mar 1, 2025
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Mar 1, 2025
@stdlib-bot
Copy link
Contributor

PR Commit Message

bench: update random value generation

PR-URL: https://github.com/stdlib-js/stdlib/pull/5528

Co-authored-by: Karan Anand <[email protected]>
Reviewed-by: Philipp Burckhardt <[email protected]>

Please review the above commit message and make any necessary adjustments.

@anandkaranubc
Copy link
Contributor Author

@Planeshifter I had a question about the test coverage for math/base/special/tanh. The only reason it doesn't have a 100% test coverage is because this block:

never gets executed as the function is always called on s >= 0 over here:

s = x * x;
z = x + ( x*s*ratval( s ) );

Do you think it can be removed or was this intentionally placed? I am sorry if I am missing something. Thanks!

@Planeshifter Planeshifter merged commit 6dd2fd1 into stdlib-js:develop Mar 1, 2025
59 checks passed
@kgryte
Copy link
Member

kgryte commented Mar 1, 2025

@anandkaranubc That is fine. That function is auto-generated. We don't need to be mucking about with removing code blocks in this case.

@kgryte
Copy link
Member

kgryte commented Mar 1, 2025

I suppose one thing we could do, however, is leave a comment indicating that it is okay if a branch in a polval or ratval function doesn't get reached. Eventually, we'll be auto-creating issues on the project repository for increasing code coverage.

That said, this is probably something we should keep in mind @Planeshifter. If we detect that one of these auto-generated files doesn't have full code coverage, we can likely safely ignore and not create a code coverage issue.

@anandkaranubc
Copy link
Contributor Author

@anandkaranubc That is fine. That function is auto-generated. We don't need to be mucking about with removing code blocks in this case.

Thanks, that makes sense. My next aim after the math/base/special refactoring was to improve the test coverage for as many files as possible. I believe this is being leveraged for good first issues then 👍

@anandkaranubc anandkaranubc deleted the tan-bench branch March 1, 2025 07:40
@kgryte
Copy link
Member

kgryte commented Mar 1, 2025

@anandkaranubc Yeah, there may be some trickier ones. E.g., beta and friends. Those are likely not good first issues.

@anandkaranubc
Copy link
Contributor Author

Makes me wonder if hyp2f1 is also in the list..... 🙃

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

Labels

Math Issue or pull request specific to math functionality. Ready To Merge A pull request which is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants