Skip to content

test: migrate stats/base/dists/geometric/median to ULP-based assertions - #16085

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-geometric-median
Oct 12, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-geometric-median

Conversation

@kgryte

@kgryte kgryte commented Oct 12, 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 @stdlib/stats/base/dists/geometric/median from relative tolerance (EPS-scaled) comparisons to ULP-based assertions using @stdlib/assert/is-almost-same-value.
  • replaces the delta/tol computation and the if ( y === expected[i] ) { ... } else { ... } branch in test/test.native.js with t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );, and drops the now unused abs and EPS imports.

Final ULP constant: 0.

The bound was tightened agentically. Starting from a high bound (64) and lowering, the minimum integer ULP value which still passes over the full fixture set is 0 (i.e., the native implementation returns bit-for-bit identical values). This was measured per-fixture over all 1000 cases in test/fixtures/julia/data.json: the maximum required ULP difference is 0, so 0 is both the measured minimum and the floor. The package test suite was run twice at the final bound, with identical results both times (1007 passing assertions per test file, 0 failures), confirming the bound is not architecture- or FMA-sensitive in this environment.

test/test.js is intentionally left unchanged: it already performs an exact comparison (t.strictEqual( y, expected[i], ... )) and contains no tolerance math, matching the existing state of sibling packages such as stats/base/dists/t/variance and stats/base/dists/negative-binomial/variance. Only the test file containing tolerance math is modified; no source, documentation, or fixture files are touched.

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 conversion mirrors the idiom used in the sibling package stats/base/dists/geometric/quantile (test: migrate stats/base/dists/geometric/quantile to ULP-based assertions #16078).
  • make lint-editorconfig-files could not be run in this environment because the editorconfig-checker binary could not be downloaded; formatting was instead verified manually (tabs for indentation, LF line endings, no trailing whitespace, single trailing newline). The project's JavaScript test lint ran via the pre-commit hook and reported no problems.

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 written primarily by Claude Code, running as an unattended scheduled task. It studied the prior art in already-converted sibling packages, applied the conversion, and determined the minimum passing ULP bound empirically over the full fixture set.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01PLFuz8CVWmXctkncnwpzcA


Generated by Claude Code

…ions

Ref: #11352

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

---
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 Good First PR A pull request resolving a Good First Issue. label Oct 12, 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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/geometric/median $\\color{green}167/167$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}167/167$
$\\color{green}+100.00\\%$

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

@stdlib-bot stdlib-bot added the Statistics Issue or pull request related to statistical functionality. label Oct 12, 2026
@kgryte kgryte added the Tests Pull requests specifically adding tests. label Oct 12, 2026
@kgryte
kgryte marked this pull request as ready for review October 12, 2026 17:58
@kgryte
kgryte requested a review from a team October 12, 2026 17:58
@kgryte
kgryte merged commit 39d1052 into develop Oct 12, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-geometric-median branch October 12, 2026 17:59
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Oct 12, 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.

3 participants