Skip to content

test: migrate stats/levene-test to ULP-based assertions - #15382

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-levene-test
Sep 21, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-levene-test

Conversation

@kgryte

@kgryte kgryte commented Sep 20, 2026

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/levene-test from relative tolerance testing (delta <= tol, where tol = 2.0 * EPS * abs( expected )) to ULP difference testing using @stdlib/assert/is-almost-same-value.
  • removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.

Each assertion uses the measured minimum ULP value which still passes. Bounds were found by scanning upward from 0 for every assertion and then confirming that N-1 fails:

Test case Quantity ULP
Levene's test for homogeneity of variance (R fixtures) pValue 2
Levene's test for homogeneity of variance (R fixtures) statistic 1

Explicit tightness check against the committed R fixtures:

pValue     N=2 -> true  | N=1 -> false
statistic  N=1 -> true  | N=0 -> false

The package has no test/test.native.js, and test/test.validate.js contains no tolerance-based assertions, so test/test.js is the only test file changed.

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.

Verification performed locally:

  • make test TESTS_FILTER=".*/stats/levene-test/.*" → 91 passing (61 in test/test.js, 30 in test/test.validate.js), 0 failing. Run twice at the final ULP values to confirm determinism.
  • make eslint-tests TESTS_FILTER=".*/stats/levene-test/.*" → clean.

Two environment notes for maintainers, neither of which is part of this diff:

  • A fresh make install-node-modules currently fails on develop: several transitive dependencies (array-includes@3.2.0, string.prototype.trim@1.2.11, string.prototype.trimend@1.0.10, es-abstract-get@1.0.0) declare es-object-atoms@^1.1.2, but the highest version published to the registry is 1.1.1. A temporary local overrides entry pinning es-object-atoms to 1.1.1 resolves the install; that workaround was used only locally and was reverted before committing.
  • The lint-editorconfig-files pre-commit step could not run in this sandbox because it downloads the editorconfig-checker binary from GitHub releases, which was network-blocked. The file was instead verified by hand against .editorconfig (LF endings, UTF-8, tab indentation, no trailing whitespace, final newline); all other pre-commit checks, including eslint-tests and commitlint, ran and passed.

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 as part of an automated, human-configured routine which converts one package per run. The ULP bounds were measured programmatically against the existing R fixtures rather than guessed.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01LdEDYG8BKCsQjS5dDNJszp


Generated by Claude Code

Replace relative tolerance comparisons with `isAlmostSameValue` ULP
difference assertions, using the minimum required ULP value for each
test case.

Ref: #11352

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

---
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 Statistics Issue or pull request related to statistical functionality. label Sep 20, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/levene-test $\\color{green}470/470$
$\\color{green}+100.00\\%$
$\\color{green}57/57$
$\\color{green}+100.00\\%$
$\\color{green}6/6$
$\\color{green}+100.00\\%$
$\\color{green}470/470$
$\\color{green}+100.00\\%$

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

Copy link
Copy Markdown
Member

⚠️ 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/levene-test, 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:41
@kgryte
kgryte requested a review from a team September 21, 2026 07:41
@kgryte
kgryte merged commit 430cdcf into develop Sep 21, 2026
50 checks passed
@kgryte
kgryte deleted the kgryte/ulp-levene-test branch September 21, 2026 07:42
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. Good First PR A pull request resolving a Good First Issue. and removed Needs Review A pull request which needs code review. labels 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