Skip to content

test: migrate stats/base/dists/lognormal/skewness to ULP-based assertions - #15381

Merged
kgryte merged 2 commits into
developfrom
philipp/ulp-lognormal-skewness
Sep 21, 2026
Merged

kgryte merged 2 commits into
developfrom
philipp/ulp-lognormal-skewness

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the tests for stats/base/dists/lognormal/skewness from computed relative-tolerance comparisons (delta = abs( y - expected[ i ] ) / tol = 1.0 * EPS * abs( expected[ i ] ), asserted via t.ok( delta <= tol, ... )) to ULP-difference assertions using @stdlib/assert/is-almost-same-value.
  • applies the migration to the two tolerance-based assertion sites in the package: one each in test/test.js and test/test.native.js. Both iterate over the same test/fixtures/julia/data.json fixture (100 points, no null/skipped entries).
  • collapses the if ( y === expected[i] ) { ... } else { ... } branch at each site into a single ULP assertion, and standardizes the assertion message to 'returns expected value'.
  • removes the now-unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires and the delta and tol variable declarations.

The remaining assertions in these files are exact comparisons (NaN propagation for NaN and non-positive sigma, and function type), which are correct as-is and are left unchanged.

Only test files are changed; no implementation, fixture, or documentation changes are included.

ULP bounds

File Implementation Previous tolerance ULP bound
test/test.js JavaScript, main export 1.0 * EPS * abs( expected ) 0
test/test.native.js C 1.0 * EPS * abs( expected ) 0

0 is the minimum integer bound N such that isAlmostSameValue( y, expected[ i ], N ) holds at every element of the fixture. It was determined by computing skewness( mu[i], sigma[i] ) for all 100 fixture points outside the test harness (via both lib/main.js and, after building the native add-on with node-gyp rebuild, lib/native.js) and comparing directly against expected[i] using @stdlib/number/float64/base/ulp-difference: the maximum observed ULP difference across the full fixture set was 0 for both implementations, so a 0-ULP (exact) bound is both sufficient and necessary — no looser bound would be tighter.

node test/test.js and node test/test.native.js were each run twice at the final bound with identical results on both runs (110/110 and 111/111 assertions passing, respectively), ruling out flakiness on this platform. npx eslint is clean for both changed files.

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 resulting diff mirrors the already-merged migrations for sibling distribution packages with the same test structure, e.g. stats/base/dists/lognormal/mean (#15353) and stats/base/dists/lognormal/mode (#15309).

Two environment notes, neither of which affected verification:

  • make install-node-modules initially failed with ETARGET for es-object-atoms@^1.1.2. The local npm packument cache was stale and served a filtered view of the registry; after npm cache clean --force, the install and make init completed and the full toolchain was available for this PR.
  • The pre-commit hook's lint-editorconfig-files step could not run, because it downloads the editorconfig-checker binary from a GitHub release that this environment cannot reach. The commit was made with SKIP_LINT_EDITORCONFIG=1 (a flag the hook itself exposes for this purpose), and the changed files were instead checked manually against .editorconfig: tabs for indentation, no trailing whitespace, and a final newline.

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

This PR was written primarily by Claude Code, running as an unattended scheduled task. It selected the package, studied previously migrated packages in the same family to match the established idiom, performed the migration, built the native add-on to verify both implementations empirically, and determined the minimum passing ULP bound over the full fixture set.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01Nj1i4n5fSMXew7XM8dHy93


Generated by Claude Code

…rtions

Ref: #11352

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

---
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 Statistics Issue or pull request related to statistical functionality. Good First PR A pull request resolving a Good First Issue. labels Sep 20, 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

stdlib-bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

No coverage information available.

Copy link
Copy Markdown
Member Author

⚠️ Issue Reference Review

An automated check found potentially unrelated issue/PR references in this PR:

Reference Assessment Reasoning
#11352 suspicious Issue #11352 is an RFC explicitly scoped to migrating math/base/special packages from relative-tolerance to ULP-based testing (its own instructions say to search for a package "in math/base/special"). This PR migrates tests for stats/base/dists/lognormal/skewness, which is outside the issue's stated scope.

Why this matters: GitHub automatically closes issues referenced with
closing keywords (Resolves, Closes, Fixes) when the PR is merged. Incorrect
references can accidentally close unrelated issues.

What to do:

  • If the reference is correct, no action needed. This check may produce
    false positives.
  • If the reference is incorrect, please update your PR description.

This assessment was generated by an AI model and is informational only.


Generated by Claude Code

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Sep 21, 2026
@kgryte
kgryte marked this pull request as ready for review September 21, 2026 07:37
@kgryte
kgryte requested a review from a team September 21, 2026 07:37
Comment thread lib/node_modules/@stdlib/stats/base/dists/lognormal/skewness/test/test.native.js Outdated
Signed-off-by: Athan <kgryte@gmail.com>
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 21, 2026
@kgryte
kgryte merged commit ad2a07e into develop Sep 21, 2026
28 checks passed
@kgryte
kgryte deleted the philipp/ulp-lognormal-skewness branch September 21, 2026 07:41
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 21, 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. Statistics Issue or pull request related to statistical functionality. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants