Skip to content

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 $\color{green}143/143$
$\color{green}+100.00\%$
$\color{green}10/10$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}143/143$
$\color{green}+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