Skip to content

Commit 19e5376

Browse files
committed
fix: implementation
--- 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 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: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent da5a2d9 commit 19e5376

File tree

5 files changed

+42
-67
lines changed

5 files changed

+42
-67
lines changed

lib/node_modules/@stdlib/stats/base/nanmax-by/lib/accessors.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
2727
// MAIN //
2828

2929
/**
30-
* Calculates the maximum value of a strided array via a callback function, ignoring `NaN` values.
30+
* Computes the maximum value of a strided array via a callback function, ignoring `NaN` values.
3131
*
3232
* @param {PositiveInteger} N - number of indexed elements
33-
* @param {Collection} x - input array/collection
34-
* @param {integer} strideX - index increment
33+
* @param {Object} x - input array object
34+
* @param {Collection} x.data - input array data
35+
* @param {Array<Function>} x.accessors - array element accessors
36+
* @param {integer} strideX - stride length
3537
* @param {NonNegativeInteger} offsetX - starting index
3638
* @param {Callback} clbk - callback
3739
* @param {*} [thisArg] - execution context
@@ -63,11 +65,12 @@ function nanmaxBy( N, x, strideX, offsetX, clbk, thisArg ) {
6365

6466
// Cache a reference to the element accessor:
6567
get = x.accessors[0];
68+
6669
if ( N <= 0 ) {
6770
return NaN;
6871
}
6972
if ( N === 1 || strideX === 0 ) {
70-
v = clbk.call( thisArg, get( xbuf, 0 ), 0, 0, x );
73+
v = clbk.call( thisArg, get( xbuf, 0 ), 0, offsetX, x );
7174
if ( v === void 0 || isnan( v ) ) {
7275
return NaN;
7376
}

lib/node_modules/@stdlib/stats/base/nanmax-by/lib/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Calculate the maximum value of a strided array via a callback function and ignoring `NaN` values.
22+
* Compute the maximum value of a strided array via a callback function and ignoring `NaN` values.
2323
*
2424
* @module @stdlib/stats/base/nanmax-by
2525
*
@@ -50,7 +50,14 @@
5050

5151
// MODULES //
5252

53+
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
5354
var main = require( './main.js' );
55+
var ndarray = require( './ndarray.js' );
56+
57+
58+
// MAIN //
59+
60+
setReadOnly( main, 'ndarray', ndarray );
5461

5562

5663
// EXPORTS //

lib/node_modules/@stdlib/stats/base/nanmax-by/lib/main.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,35 @@
2020

2121
// MODULES //
2222

23-
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
24-
var nanmaxBy = require( './nanmax_by.js' );
23+
var stride2offset = require( '@stdlib/strided/base/stride2offset' );
2524
var ndarray = require( './ndarray.js' );
2625

2726

2827
// MAIN //
2928

30-
setReadOnly( nanmaxBy, 'ndarray', ndarray );
29+
/**
30+
* Computes the maximum value of a strided array via a callback function, ignoring `NaN` values.
31+
*
32+
* @param {PositiveInteger} N - number of indexed elements
33+
* @param {Collection} x - input array/collection
34+
* @param {integer} strideX - index increment
35+
* @param {Callback} clbk - callback
36+
* @param {*} [thisArg] - execution context
37+
* @returns {number} maximum value
38+
*
39+
* @example
40+
* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
41+
*
42+
* function accessor( v ) {
43+
* return v * 2.0;
44+
* }
45+
*
46+
* var v = nanmaxBy( x.length, x, 1, accessor );
47+
* // returns 8.0
48+
*/
49+
function nanmaxBy( N, x, strideX, clbk, thisArg ) {
50+
return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg );
51+
}
3152

3253

3354
// EXPORTS //

lib/node_modules/@stdlib/stats/base/nanmax-by/lib/nanmax_by.js

Lines changed: 0 additions & 56 deletions
This file was deleted.

lib/node_modules/@stdlib/stats/base/nanmax-by/lib/ndarray.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2025 The Stdlib Authors.
4+
* Copyright (c) 2020 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ var accessors = require( './accessors.js' );
2929
// MAIN //
3030

3131
/**
32-
* Calculates the maximum value of a strided array via a callback function, ignoring `NaN` values.
32+
* Computes the maximum value of a strided array via a callback function, ignoring `NaN` values.
3333
*
3434
* @param {PositiveInteger} N - number of indexed elements
3535
* @param {Collection} x - input array/collection
@@ -64,7 +64,7 @@ function nanmaxBy( N, x, strideX, offsetX, clbk, thisArg ) {
6464
return accessors( N, o, strideX, offsetX, clbk, thisArg );
6565
}
6666
if ( N === 1 || strideX === 0 ) {
67-
v = clbk.call( thisArg, x[ 0 ], 0, 0, x );
67+
v = clbk.call( thisArg, x[ offsetX ], 0, offsetX, x );
6868
if ( v === void 0 ) {
6969
return NaN;
7070
}

0 commit comments

Comments
 (0)