test: migrate math/base/special/cscd to ULP-based assertions - #14313
Merged
Conversation
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves a part of #11352.
Description
This pull request:
math/base/special/cscdfrom relative tolerance testing (delta <= tol, wheretol = 1.4 * EPS * abs( expected[ i ] )) to ULP difference testing using@stdlib/assert/is-almost-same-value.Both
test/test.jsandtest/test.native.jsare updated. In each file, the two fixture loops (negative and positive values) now assertThe now-unused
@stdlib/constants/float64/epsand@stdlib/math/base/special/absrequires are removed, and the@stdlib/assert/is-almost-same-valuerequire is added. The pre-existingexpected[ i ] === nullbranches (which assert exact-Infinity/+Infinityreturns at multiples of180) are left unchanged, as those are exact comparisons rather than tolerance-based ones.ULP constant
The measured minimum ULP value is 2, used in all four converted fixture loops:
test/test.jstest/test.jstest/test.native.jstest/test.native.jsThe bound was tightened by measuring the exact worst-case ULP difference over the full Julia fixture sets (999 non-null cases per set): the maximum observed difference is exactly 2 ULP in both the negative and positive sets, and the suite fails at 1 ULP. The test suite was run twice at the final value to confirm determinism (2009 passing assertions, no failures, both runs).
Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
test/test.native.jsuses the same 2 ULP bound astest/test.js. The native addon was not built in the environment used to author this change, so those tests were skipped locally and the C implementation's ULP behavior was not measured directly. The bound mirrors the JavaScript measurement on the grounds that both implementations are the same expression (1.0 / sind( x )inlib/main.jsandstdlib_base_cscdinsrc/main.c). Happy to adjust if reviewers would prefer a separately measured value for the native tests.Other
The conversion mirrors the idiom already used by the sibling package
math/base/special/cotd, which has the same fixture structure, including thenullspecial-case branches.Verification performed:
make test TESTS_FILTER=".*/math/base/special/cscd/.*"— passing (run twice)make eslint-tests TESTS_FILTER=".*/math/base/special/cscd/.*"— cleanChecklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written by Claude Code running as an unattended scheduled task. The tolerance-to-ULP conversion, the ULP bound search, and the local verification runs were all performed by the agent.
@stdlib-js/reviewers
Generated by Claude Code