Skip to content

test: migrate stats/kde2d to ULP-based assertions - #15331

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-stats-kde2d
Draft

kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-stats-kde2d

Conversation

@kgryte

@kgryte kgryte commented Sep 18, 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/kde2d from relative tolerance assertions (delta <= tol, where tol = N * EPS * abs( expected )) to ULP-based assertions using @stdlib/assert/is-almost-same-value.
  • removes the now unused @stdlib/constants/float64/eps and @stdlib/math/base/special/abs requires and the associated delta/tol scratch variables.

Only test/test.js is modified; the package has no test/test.native.js. No implementation, fixture, or documentation files are touched.

ULP bounds

Each bound is the measured minimum which passes over the full fixture set. The minima were computed directly from @stdlib/number/float64/base/ulp-difference across every fixture element and then confirmed empirically by re-running the suite at N-1, which fails in each case:

Test case Output Previous tolerance Final ULP N-1 result
small dataset x 200.0 * EPS 0 n/a (floor)
small dataset y 200.0 * EPS 0 n/a (floor)
small dataset z 1500.0 * EPS 4 10 failures at 3
medium dataset x 500.0 * EPS 0 n/a (floor)
medium dataset y 200.0 * EPS 0 n/a (floor)
medium dataset z 2000.0 * EPS 28 1 failure at 27
large dataset x 250.0 * EPS 0 n/a (floor)
large dataset y 500.0 * EPS 0 n/a (floor)
large dataset z 2000.0 * EPS 17 1 failure at 16

The x and y grid values match the R reference fixtures exactly, hence a bound of 0.

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.

  • make test TESTS_FILTER=".*/stats/kde2d/.*" passes: 2098/2098 assertions, matching the assertion count before the migration. The suite was run twice at the final ULP values to confirm the results are deterministic.
  • eslint --config etc/eslint/.eslintrc.tests.js reports no errors for the modified file.

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, unattended migration task: it selected the package, mirrored the conversion idiom from previously merged stats/* ULP migrations, measured the minimum ULP bounds, and verified the suite locally.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_012oJYd2qY2kvRKBr7pDJbkz


Generated by Claude Code

Replace relative tolerance assertions in the `stats/kde2d` tests with
ULP-based assertions using `@stdlib/assert/is-almost-same-value`. ULP
bounds were tightened to the measured minimum which passes over the full
fixture set.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012oJYd2qY2kvRKBr7pDJbkz
@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 18, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/kde2d $\\color{red}1226/1312$
$\\color{green}+93.45\\%$
$\\color{red}96/103$
$\\color{green}+93.20\\%$
$\\color{red}13/20$
$\\color{green}+65.00\\%$
$\\color{red}1226/1312$
$\\color{green}+93.45\\%$

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

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants