Skip to content

feat: add C implementation for stats/base/dists/invgamma/quantile#13640

Merged
Planeshifter merged 11 commits into
stdlib-js:developfrom
ujjwalv01:feat-add-invgamma-quantile-c
Jul 25, 2026
Merged

feat: add C implementation for stats/base/dists/invgamma/quantile#13640
Planeshifter merged 11 commits into
stdlib-js:developfrom
ujjwalv01:feat-add-invgamma-quantile-c

Conversation

@ujjwalv01

Copy link
Copy Markdown
Contributor

Resolves #3677.

Description

What is the purpose of this pull request?

This pull request:

  • Adds a native C implementation for the @stdlib/stats/base/dists/invgamma/quantile package.
  • Adds N-API bindings to wrap the C logic for Node.js usage.
  • Updates lib/index.js to intelligently fall back to the pure JavaScript implementation if the native addon fails to compile or load.
  • Adds C and JS native benchmarks, C examples, and native tests.
  • Updates the package documentation (README.md) to document the newly exposed C API.

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.

No.

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.".

I consulted an AI assistant to understand the codebase structure and how native C addons and bindings are scaffolded in stdlib, but the proposed changes were manually implemented and integrated.


@stdlib-js/reviewers

@ujjwalv01
ujjwalv01 requested a review from a team July 24, 2026 10:10
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. Good First PR A pull request resolving a Good First Issue. labels Jul 24, 2026
@ujjwalv01
ujjwalv01 marked this pull request as draft July 24, 2026 10:27
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Jul 24, 2026
@stdlib-bot

stdlib-bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/invgamma/quantile $\\color{green}307/307$
$\\color{green}+0.00\\%$
$\\color{green}24/24$
$\\color{green}+0.00\\%$
$\\color{green}4/4$
$\\color{green}+0.00\\%$
$\\color{green}307/307$
$\\color{green}+0.00\\%$

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

@ujjwalv01
ujjwalv01 marked this pull request as ready for review July 24, 2026 15:07
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jul 24, 2026
…overage, and remove redundant include

- Add missing `// returns NaN` on non-positive shape parameter example in native.js and main.js
- Fix 'rate parameter' to 'scale parameter' in main.js JSDoc
- Remove redundant `<stdbool.h>` include from src/main.c
- Fix test.native.js import ordering (tryRequire after tape, add PINF)
- Rename tape descriptions from 'negative' to 'nonpositive' for alpha/beta
- Add alpha=0 and beta=0 edge-case tests
- Add full PINF/NINF/NaN combination sub-assertions matching test.quantile.js

---
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: passed
  - 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: passed
  - 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: passed
  - 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
---
…ntions

- Revert lib/index.js to use direct main export without tryRequire
  (matching all 458 other distribution packages)
- Replace rand_double()/raw rand() with random_uniform(min,max) helper
  in benchmark.c and example.c
- Use pre-generated arrays with i%100 indexing in benchmark.c
- Use convention-matching print_results(elapsed) signature
- Update NAME define to 'invgamma-quantile'
- Use 25 iterations and Unicode symbols in example.c
- Remove return 0 from main() in benchmark.c and example.c
- Sync README C example with example.c

---
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: passed
  - task: lint_markdown_pkg_readmes
    status: passed
  - 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: passed
  - 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: passed
  - task: lint_c_benchmarks
    status: passed
  - 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
---
Comment thread lib/node_modules/@stdlib/stats/base/dists/invgamma/quantile/README.md Outdated
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
Planeshifter
Planeshifter previously approved these changes Jul 25, 2026

@Planeshifter Planeshifter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after clean-up. Thanks, @ujjwalv01!

@Planeshifter Planeshifter added the Ready To Merge A pull request which is ready to be merged. label Jul 25, 2026
@stdlib-bot

stdlib-bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

PR Commit Message

feat: add C implementation for `stats/base/dists/invgamma/quantile`

PR-URL: https://github.com/stdlib-js/stdlib/pull/13640
Closes: https://github.com/stdlib-js/stdlib/issues/3677
Ref: https://github.com/stdlib-js/stdlib/issues/3669

Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com>
Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>

Please review the above commit message and make any necessary adjustments.

⚠️ Action Required: This PR references tracking issues. Please update the PR description to replace any "Closes", "Fixes", or "Resolves" keywords with "Ref" when referencing these issues.

@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Jul 25, 2026
…ve.js

---
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: passed
  - 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: passed
  - 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
---
Planeshifter
Planeshifter previously approved these changes Jul 25, 2026
@Planeshifter Planeshifter changed the title feat: add C implementation for invgamma/quantile feat: add C implementation for stats/base/dists/invgamma/quantile Jul 25, 2026
- Add missing @Private annotation to lib/native.js
- Swap addon.c include order (napi header first)
- Reorder NaN checks in src/main.c to match signature order
- Add wasm:false to manifest.json options and confs
- Move napi/ternary dep to first position in build confs
- Fix package.json keywords: cdf->quantile, dist->dists,
  add 'quantile function', remove c/addon/napi
- Use @stdlib/random/array/uniform in benchmark.native.js
- Fix operator spacing in benchmark.c random_uniform and tic
- Swap FIXTURES/VARIABLES section ordering in test.native.js
- Fix inconsistent alpha: spacing in test assertion messages
- Restore verbose HTML comments and notes section in README

---
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: passed
  - task: lint_markdown_pkg_readmes
    status: passed
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: passed
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: passed
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: passed
  - 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
---
…tions

---
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: passed
  - task: lint_markdown_pkg_readmes
    status: passed
  - 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
---
@Planeshifter
Planeshifter merged commit 525c0cb into stdlib-js:develop Jul 25, 2026
13 checks passed
@stdlib-bot stdlib-bot removed the Ready To Merge A pull request which is ready to be merged. label Jul 25, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: Add C implementation for @stdlib/stats/base/dists/invgamma/quantile

3 participants