Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add stats/incr/nanmminmax #6422

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

abhishekblue
Copy link
Contributor

Resolves #5596

Description

What is the purpose of this pull request?

This pull request:

  • introduces the @stdlib/stats/incr/nanmminmax package, which incrementally computes a harmonic mean, ignoring NaN values.

Related Issues

Does this pull request have any related issues?

This pull request:

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.


@stdlib-js/reviewers

@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 Mar 28, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Mar 28, 2025

Coverage Report

Package Statements Branches Functions Lines
stats/incr/nanmminmax 143 / 143
+ 100.00 %
10 / 10
+ 100.00 %
2 / 2
+ 100.00 %
143 / 143
+ 100.00 %

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


# incrnanmminmax

> Compute a moving minimum and maximum incrementally ignoring `NaN` values.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
> Compute a moving minimum and maximum incrementally ignoring `NaN` values.
> Compute a moving minimum and maximum incrementally, ignoring `NaN` values.


<section class="related">

* * *
Copy link
Contributor

Choose a reason for hiding this comment

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

remove L135-145


<section class="links">

<!-- <related-links> -->
Copy link
Contributor

Choose a reason for hiding this comment

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

remove L154-168

var i;
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
f = incrnanmminmax( (i%5)+1 );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
f = incrnanmminmax( (i%5)+1 );
f = incrnanmminmax( ( i%5 ) + 1 );

import { ArrayLike } from '@stdlib/types/array';

/**
* If provided a value, the accumulator function returns updated minimum and maximum values. If not provided a value, the accumulator function returns the current minimum and maximum values.
Copy link
Contributor

Choose a reason for hiding this comment

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

There is repetitive code in this file so please fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have noticed that as well and didn't understand that too but this repetitive code is also present in mminmax package as well.

* @param {number} [x] - new value
* @returns {(ArrayLikeObject|null)} min/max array or null
*/
function accumulator(x) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
function accumulator(x) {
function accumulator( x ) {

* @returns {(ArrayLikeObject|null)} min/max array or null
*/
function accumulator(x) {
if (arguments.length === 0 || isnan(x)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (arguments.length === 0 || isnan(x)) {
if ( arguments.length === 0 || isnan( x ) ) {

if (arguments.length === 0 || isnan(x)) {
return mminmax();
}
return mminmax(x);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return mminmax(x);
return mminmax( x );

{
"name": "@stdlib/stats/incr/nanmminmax",
"version": "0.0.0",
"description": "Compute a moving minimum and maximum incrementally.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"description": "Compute a moving minimum and maximum incrementally.",
"description": "Compute a moving minimum and maximum incrementally, ignoring `NaN` values.",

];

for ( i = 0; i < values.length; i++ ) {
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided '+values[ i ] );

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. Needs Review A pull request which needs code review. Statistics Issue or pull request related to statistical functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: add stats/incr/nanmminmax
3 participants