test: migrate stats/base/dists/logistic/entropy to ULP-based assertions - #14218
Conversation
…ions Replace relative tolerance assertions with ULP-based assertions using `@stdlib/assert/is-almost-same-value`. All fixture values are returned exactly by both the JavaScript and native implementations, so the required ULP bound is 0. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3SrW8juEFjGc5kVqJDtR1 --- 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: na - 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 ---
|
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! |
Coverage Report
The above coverage report was generated for the changes in this PR. |
Description
This pull request:
stats/base/dists/logistic/entropyfrom relative tolerance (EPS-based) comparisons to ULP-based assertions, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.Specifically, in both
test/test.jsandtest/test.native.js, the fixture loop'sdelta/tolcomputation is replaced withadding a
@stdlib/assert/is-almost-same-valuerequire and dropping the now-unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires.Final ULP constant:
0(bothtest.jsandtest.native.js).The bound was tightened empirically rather than assumed. Starting from
64and lowering, the minimum passing integer over the full fixture set (100 non-nullcases) is0:N = 0: 110/110 assertions pass.The maximum observed ULP difference across the fixtures is
0; every fixture value is returned exactly, so the previous2.0 * EPSrelative tolerance was never actually exercised.test.jswas run twice at the finalNwith identical results.The native test is skipped locally (the addon is not built in this environment), but the same bound is safe by construction, and this was checked rather than assumed. Both
lib/main.jsandsrc/main.ccomputeln( s ) + 2.0using stdlib's ownln, so the C implementation was compiled directly (stdlib_base_lnplus its dependency closure, viagcc) and evaluated over the 100 fixturesvalues: the results are bit-identical to the JavaScript implementation and match the Julia fixtures to0ULP. The single addition admits no FMA contraction, so the measured bound carries over to the native path.Only the two test files are modified; no implementation, fixture, or documentation changes.
Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
No.
Other
make install-node-modulesinitially failed in the authoring environment withETARGET: No matching version found for es-object-atoms@^1.1.2(the reachable registry publishes only up to1.1.1). This was worked around by installing the dev dependencies into an isolated scratch tree with an npmoverridesentry pinninges-object-atomsto1.1.1, so the project toolchain could be exercised for real:make test TESTS_FILTER=".*/stats/base/dists/logistic/entropy/.*"— green (110 passing; native suite skipped, addon not built);eslintwithetc/eslint/.eslintrc.tests.json both changed files — clean;pre-commithook's filename,package.json, REPL-help, and JavaScript test lint steps — clean.The one check that could not be run is
lint-editorconfig-files, which downloads theeditorconfig-checkerbinary from GitHub and is blocked by this environment's network policy. The changed files were verified manually against.editorconfiginstead: LF line endings, UTF-8, tab indentation, no trailing whitespace, final newline present.Leaving this as a draft so CI can confirm the full lint and the native builds.
Checklist
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. It surveyed prior merged conversions (e.g. #14211, #14213) to match the established idiom, applied the test changes, and determined the minimum ULP bound empirically against the full fixture set.
@stdlib-js/reviewers
Generated by Claude Code