Skip to content

test: migrate math/base/special/cos to ULP-based testing#11281

Merged
kgryte merged 5 commits intostdlib-js:developfrom
nirmaljb:ulp/cos
Apr 3, 2026
Merged

test: migrate math/base/special/cos to ULP-based testing#11281
kgryte merged 5 commits intostdlib-js:developfrom
nirmaljb:ulp/cos

Conversation

@nirmaljb
Copy link
Copy Markdown
Contributor

@nirmaljb nirmaljb commented Apr 3, 2026


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: passed
  • task: lint_typescript_tests status: na
  • task: lint_license_headers status: passed ---

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

Description

What is the purpose of this pull request?

This pull request:

  • Migrates existing test cases from relative error-based tolerance checks to ULP-based comparisons
  • Uses @stdlib/assert/is-almost-same-value for testing

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

---
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: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. labels Apr 3, 2026
@stdlib-bot
Copy link
Copy Markdown
Contributor

stdlib-bot commented Apr 3, 2026

Coverage Report

Package Statements Branches Functions Lines
math/base/special/cos $\color{green}236/236$
$\color{green}+0.00%$
$\color{green}14/14$
$\color{green}+0.00%$
$\color{green}2/2$
$\color{green}+0.00%$
$\color{green}236/236$
$\color{green}+0.00%$

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

@nirmaljb
Copy link
Copy Markdown
Contributor Author

nirmaljb commented Apr 3, 2026

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Apr 3, 2026
@stdlib-bot
Copy link
Copy Markdown
Contributor

/stdlib update-copyright-years

@nirmaljb, the slash command failed to complete. Please check the workflow logs for details.

View workflow run

@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Apr 3, 2026
---
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: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@kgryte kgryte self-requested a review April 3, 2026 08:22
@kgryte kgryte added 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. review: 3 and removed Needs Review A pull request which needs code review. labels Apr 3, 2026
@kgryte kgryte changed the title test: migrated math/base/special/cos to ULP-based testing test: migrate math/base/special/cos to ULP-based testing Apr 3, 2026
---
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: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@nirmaljb
Copy link
Copy Markdown
Contributor Author

nirmaljb commented Apr 3, 2026

@kgryte I've addressed your reviews and made those changes.

@nirmaljb nirmaljb requested a review from kgryte April 3, 2026 09:12
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Apr 3, 2026
@github-actions github-actions bot mentioned this pull request Apr 3, 2026
@anandkaranubc anandkaranubc self-requested a review April 3, 2026 14:25
anandkaranubc and others added 2 commits April 3, 2026 10:43
---
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: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@nirmaljb
Copy link
Copy Markdown
Contributor Author

nirmaljb commented Apr 3, 2026

@anandkaranubc I've addressed the changes that you suggested, please take a look.

@kgryte kgryte removed the Needs Changes Pull request which needs changes before being merged. label Apr 3, 2026
@kgryte kgryte removed the Needs Review A pull request which needs code review. label Apr 3, 2026
Copy link
Copy Markdown
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.

LGTM.

@nirmaljb Before opening an RFC, we should also do a migration for a package requiring tolerances greater than 1 ULP. E.g., https://github.com/stdlib-js/stdlib/tree/8b19d00b71edcd61143c31573eab59cfc6936ab4/lib/node_modules/%40stdlib/math/base/special/ellipe.

I am thinking we should also provide a reference PR which is a little less straightforward and requires fiddling with the tolerances a bit.

@kgryte kgryte merged commit 2840211 into stdlib-js:develop Apr 3, 2026
13 checks passed
@nirmaljb
Copy link
Copy Markdown
Contributor Author

nirmaljb commented Apr 3, 2026

@kgryte Thank you for the merge. I will search for such functions that require greater than 1 ulp and confirm with you or @anandkaranubc before opening the RFC.

@anandkaranubc
Copy link
Copy Markdown
Contributor

anandkaranubc commented Apr 3, 2026

Completely second what @kgryte mentioned. Also, while making these changes, make sure the ULP difference you use is the smallest possible for that case. This also means that if you can use t.strictEqual(y, expected[i], ...) instead of t.strictEqual(isAlmostSameValue(y, expected[i], ...), ...), it is highly important to do so.

cc: @nirmaljb

@nirmaljb
Copy link
Copy Markdown
Contributor Author

nirmaljb commented Apr 4, 2026

@anandkaranubc Wouldn't that mean that I have to use this branch?

if ( y === expected[ i ] ) {
    t.strictEqual( y, expected[ i ], ...);

@kgryte
Copy link
Copy Markdown
Member

kgryte commented Apr 4, 2026

@nirmaljb No, he is suggesting that if you don't have to use approximate equality tests, then don't. So if all the test fixtures match the expected results exactly, there is no need to use isAlmostSameValue at all.

@nirmaljb
Copy link
Copy Markdown
Contributor Author

nirmaljb commented Apr 4, 2026

Got it! @kgryte

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

Labels

difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. Math Issue or pull request specific to math functionality. review: 3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants