Skip to content

test: migrate simulate/iter/triangle-wave to ULP-based assertions - #15571

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-simulate-iter-triangle-wave
Sep 26, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-simulate-iter-triangle-wave

Conversation

@kgryte

@kgryte kgryte commented Sep 26, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

Specifically, in test/test.js:

  • adds the @stdlib/assert/is-almost-same-value require and removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.
  • removes the delta/tol declarations and the delta = abs( ... ) / tol = 1.0 * EPS * abs( ... ) tolerance computations.
  • collapses each if ( actual.value === expected[ i ].value ) { ... } else { ... } comparison into a single t.strictEqual( isAlmostSameValue( actual.value, expected[ i ].value, 0 ), true, 'returns expected value' ); assertion.

There are 8 converted assertion sites (the seven waveform tests and the iteration-limit test). No other files are touched, and the total assertion count is unchanged at 240.

ULP bound

The final ULP constant is 0 at every one of the 8 assertion sites, which is the measured minimum.

To determine this, each assertion site was instrumented to search for the smallest maxULP for which isAlmostSameValue( actual.value, expected[ i ].value, n ) returns true, and the maximum such value over the full fixture set was recorded per site. Every site measured 0, meaning the returned values are bit-identical to the expected values (0 is the tightest bound the assertion accepts, as maxULP === 0 delegates to isSameValue, so -0/+0 remain distinguishable). The suite was then run twice at the final bound to confirm determinism, passing 240/240 both times:

$ make test TESTS_FILTER=".*/simulate/iter/triangle-wave/.*"
  total:     240
  passing:   240

This matches the bound used by the already-converted sibling package simulate/iter/sawtooth-wave, which also uses 0 for its waveform tests.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

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.

The idiom was mirrored from the already-converted packages in the same family (simulate/iter/sawtooth-wave, simulate/iter/hann-pulse, simulate/iter/flat-top-pulse), including the placement of the isAlmostSameValue require and the inline ULP literal.

make lint-javascript-files cannot complete in the authoring environment because the editorconfig-checker binary download is blocked, so that one check was skipped locally; the file was instead verified by hand to be LF-only, tab-indented, free of trailing whitespace, and to end in a final newline. The test-file ESLint configuration (etc/eslint/.eslintrc.tests.js) did run and reported no problems.

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.".

This PR was authored by Claude Code running as an unattended scheduled task. It selected the package, mirrored the conversion idiom from already-converted packages in the same family, applied the test changes, measured the minimum ULP bound empirically, and verified the suite and lint.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01UDitDiLoTNhLZNVBzzdAYE


Generated by Claude Code

Replace relative tolerance comparisons with `isAlmostSameValue` ULP
difference assertions. Each assertion site uses the minimum required ULP
value, which is `0` throughout, as the returned values are bit-identical
to the expected values.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UDitDiLoTNhLZNVBzzdAYE

---
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: skipped
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - 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 the Good First PR A pull request resolving a Good First Issue. label Sep 26, 2026
@stdlib-bot

Copy link
Copy Markdown
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
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
simulate/iter/triangle-wave $\\color{green}304/304$
$\\color{green}+100.00\\%$
$\\color{green}32/32$
$\\color{green}+100.00\\%$
$\\color{green}5/5$
$\\color{green}+100.00\\%$
$\\color{green}304/304$
$\\color{green}+100.00\\%$

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

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Sep 26, 2026
@kgryte
kgryte marked this pull request as ready for review September 26, 2026 20:50
@kgryte
kgryte requested a review from a team September 26, 2026 20:50
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 26, 2026
@kgryte
kgryte merged commit 4a73a48 into develop Sep 26, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-simulate-iter-triangle-wave branch September 26, 2026 20:51
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Good First PR A pull request resolving a Good First Issue. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants