From e2d5087f16faf3edf8ed7d390e71ab3b1790bf2f Mon Sep 17 00:00:00 2001 From: Dhruvil Mehta Date: Sat, 8 Mar 2025 23:11:49 -0800 Subject: [PATCH 1/9] feat: added accessor protocol to range-by --- 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: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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: 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: passed - task: lint_license_headers status: passed --- --- .../@stdlib/stats/base/range-by/README.md | 12 +- .../base/range-by/benchmark/benchmark.js | 21 ++-- .../range-by/benchmark/benchmark.ndarray.js | 2 +- .../@stdlib/stats/base/range-by/docs/repl.txt | 18 +-- .../stats/base/range-by/docs/types/index.d.ts | 17 ++- .../stats/base/range-by/docs/types/test.ts | 11 +- .../stats/base/range-by/examples/index.js | 2 +- .../stats/base/range-by/lib/accessors.js | 109 ++++++++++++++++++ .../@stdlib/stats/base/range-by/lib/index.js | 2 +- .../@stdlib/stats/base/range-by/lib/main.js | 2 +- .../stats/base/range-by/lib/ndarray.js | 30 +++-- .../stats/base/range-by/lib/range_by.js | 66 ++--------- .../@stdlib/stats/base/range-by/test/test.js | 2 +- .../stats/base/range-by/test/test.ndarray.js | 70 ++++++++++- .../stats/base/range-by/test/test.range_by.js | 71 +++++++++++- 15 files changed, 320 insertions(+), 115 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/range-by/lib/accessors.js diff --git a/lib/node_modules/@stdlib/stats/base/range-by/README.md b/lib/node_modules/@stdlib/stats/base/range-by/README.md index 6201414d727a..a75df487f68a 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/README.md +++ b/lib/node_modules/@stdlib/stats/base/range-by/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2020 The Stdlib Authors. +Copyright (c) 2025 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ The [**range**][range] is defined as the difference between the maximum and mini var rangeBy = require( '@stdlib/stats/base/range-by' ); ``` -#### rangeBy( N, x, stride, clbk\[, thisArg] ) +#### rangeBy( N, x, strideX, clbk\[, thisArg] ) Calculates the [range][range] of strided array `x` via a callback function. @@ -56,8 +56,8 @@ var v = rangeBy( x.length, x, 1, accessor ); The function has the following parameters: - **N**: number of indexed elements. -- **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions). -- **stride**: index increment. +- **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions). +- **strideX**: index increment. - **clbk**: callback function. - **thisArg**: execution context (_optional_). @@ -89,7 +89,7 @@ var cnt = context.count; // returns 8 ``` -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to access every other element +The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. For example, to access every other element ```javascript var floor = require( '@stdlib/math/base/special/floor' ); @@ -127,7 +127,7 @@ var v = rangeBy( N, x1, 2, accessor ); // returns 8.0 ``` -#### rangeBy.ndarray( N, x, stride, offset, clbk\[, thisArg] ) +#### rangeBy.ndarray( N, x, strideX, offset, clbk\[, thisArg] ) Calculates the [range][range] of strided array `x` via a callback function and using alternative indexing semantics. diff --git a/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.js index 17e8ef1c2c19..5e2a32839092 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,11 +21,18 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; -var rangeBy = require( './../lib/range_by.js' ); +var rangeBy = require( './../lib/main.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; // FUNCTIONS // @@ -49,13 +56,7 @@ function accessor( value ) { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( ( randu()*20.0 ) - 10.0 ); - } + var x = uniform( len, -10, 10, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.ndarray.js index 427ab185fd51..53ddf8c546cf 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/range-by/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range-by/docs/repl.txt index a5427e4d614e..fc3445e704d6 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range-by/docs/repl.txt @@ -1,5 +1,4 @@ - -{{alias}}( N, x, stride, clbk[, thisArg] ) +{{alias}}( N, x, strideX, clbk[, thisArg] ) Calculates the range of a strided array via a callback function. The `N` and `stride` parameters determine which elements in `x` are accessed @@ -14,7 +13,7 @@ - value: array element. - aidx: array index. - - sidx: strided index (offset + aidx*stride). + - sidx: strided index (offsetX + aidx*strideX). - array: the input array. The callback function should return a numeric value. @@ -31,7 +30,7 @@ Input array/collection. If provided an object, the object must be array- like (excluding strings and functions). - stride: integer + strideX: integer Index increment for `x`. clbk: Function @@ -53,7 +52,7 @@ > {{alias}}( x.length, x, 1, accessor ) 18.0 - // Using `N` and `stride` parameters: + // Using `N` and `strideX` parameters: > x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); > {{alias}}( N, x, 2, accessor ) @@ -66,12 +65,13 @@ > {{alias}}( N, x1, 2, accessor ) 8.0 -{{alias}}.ndarray( N, x, stride, offset, clbk[, thisArg] ) + +{{alias}}.ndarray( N, x, strideX, offsetX, clbk[, thisArg] ) Calculates the range of a strided array via a callback function and using alternative indexing semantics. While typed array views mandate a view offset based on the underlying - buffer, the `offset` parameter supports indexing semantics based on a + buffer, the `offsetX` parameter supports indexing semantics based on a starting index. Parameters @@ -83,10 +83,10 @@ Input array/collection. If provided an object, the object must be array- like (excluding strings and functions). - stride: integer + strideX: integer Index increment for `x`. - offset: integer + offsetX: integer Starting index of `x`. clbk: Function diff --git a/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts index ee65d0f01b7b..3de76051c8b1 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,14 @@ /// -import { Collection } from '@stdlib/types/array'; +// import { Collection } from '@stdlib/types/array'; +import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; + + +/** +* Input array. +*/ +type InputArray = NumericArray | Collection | AccessorArrayLike; /** * Returns an accessed value. @@ -65,7 +72,7 @@ type Ternary = ( this: U, value: T, aidx: number, sidx: number ) => number * @param array - input array * @returns accessed value */ -type Quaternary = ( this: U, value: T, aidx: number, sidx: number, array: Collection ) => number | void; +type Quaternary = ( this: U, value: T, aidx: number, sidx: number, array: InputArray ) => number | void; /** * Returns an accessed value. @@ -113,7 +120,7 @@ interface Routine { * var v = rangeBy( x.length, x, 1, accessor ); * // returns 18.0 */ - ( N: number, x: Collection, stride: number, clbk: Callback, thisArg?: ThisParameterType> ): number; + ( N: number, x: InputArray, stride: number, clbk: Callback, thisArg?: ThisParameterType> ): number; /** * Calculates the range of a strided array via a callback function and using alternative indexing semantics. @@ -147,7 +154,7 @@ interface Routine { * var v = rangeBy.ndarray( x.length, x, 1, 0, accessor ); * // returns 18.0 */ - ndarray( N: number, x: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): number; + ndarray( N: number, x: InputArray, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): number; } /** diff --git a/lib/node_modules/@stdlib/stats/base/range-by/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/range-by/docs/types/test.ts index f1f5674896d9..dff4896a2488 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/range-by/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,8 @@ * limitations under the License. */ -import rangeBy = require( './index' ); +import rangeBy = require( '@stdlib/stats/base/range-by' ); +import AccessorArray = require( '@stdlib/array/base/accessor' ); const accessor = (): number => { return 5.0; @@ -31,6 +32,8 @@ const accessor = (): number => { rangeBy( x.length, x, 1, accessor ); // $ExpectType number rangeBy( x.length, x, 1, accessor, {} ); // $ExpectType number + rangeBy( x.length, new AccessorArray ( x ), 1, accessor ); // $ExpectType number + rangeBy( x.length, new AccessorArray ( x ), 1, accessor, {} ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... @@ -70,7 +73,7 @@ const accessor = (): number => { rangeBy( x.length, x, undefined, accessor ); // $ExpectError rangeBy( x.length, x, [], accessor ); // $ExpectError rangeBy( x.length, x, {}, accessor ); // $ExpectError - rangeBy( x.length, x, ( x: number, accessor ): number => x, accessor ); // $ExpectError + rangeBy( x.length, x, ( x: number ): number => x, accessor ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a function... @@ -103,6 +106,8 @@ const accessor = (): number => { rangeBy.ndarray( x.length, x, 1, 0, accessor ); // $ExpectType number rangeBy.ndarray( x.length, x, 1, 0, accessor, {} ); // $ExpectType number + rangeBy.ndarray( x.length, new AccessorArray ( x ), 1, 0, accessor ); // $ExpectType number + rangeBy.ndarray( x.length, new AccessorArray ( x ), 1, 0, accessor, {} ); // $ExpectType number } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... diff --git a/lib/node_modules/@stdlib/stats/base/range-by/examples/index.js b/lib/node_modules/@stdlib/stats/base/range-by/examples/index.js index 2c25e656bb8b..c2cae6048cd5 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/accessors.js new file mode 100644 index 000000000000..ca5c6b182781 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/range-by/lib/accessors.js @@ -0,0 +1,109 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Calculates the range of a strided array via a callback function. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {NumericArray|Collection|AccessorArrayLike} x - input array/collection +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index +* @param {Callback} clbk - callback +* @param {*} [thisArg] - execution context +* @returns {number} range +* +* @example +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ]; +* +* function accessor( v ) { +* if ( v === void 0 ) { +* return; +* } +* return v * 2.0; +* } +* +* var v = rangeBy( x.length, arraylike2object(x), 1, 0, accessor ); +* // returns 18.0 +*/ +function rangeBy( N, x, strideX, offsetX, clbk, thisArg) { + var xbuf; + var get; + var max; + var min; + var ix; + var v; + var i; + + xbuf = x.data; + + get = x.accessors[ 0 ]; + + if ( N === 1 || strideX === 0 ) { + v = clbk.call( thisArg, get(xbuf, offsetX), 0, 0, x ); + if ( v === void 0 || isnan( v ) ) { + return NaN; + } + return 0.0; + } + + ix = offsetX; + for ( i = 0; i < N; i++ ) { + min = clbk.call( thisArg, get(xbuf, ix), i, ix, x ); + if ( min !== void 0 ) { + break; + } + ix += strideX; + } + if ( i === N ) { + return NaN; + } + max = min; + i += 1; + for ( i; i < N; i++ ) { + ix += strideX; + v = clbk.call( thisArg, get(xbuf, ix), i, ix, x ); + if ( v === void 0 ) { + continue; + } + if ( isnan( v ) ) { + return v; + } + if ( v < min ) { + min = v; + } else if ( v > max ) { + max = v; + } + } + return max - min; +} + + +// EXPORTS // + +module.exports = rangeBy; diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/index.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/index.js index dfc0f442b883..e10d23e20836 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js index 237cd1ff444b..14a623095f81 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/ndarray.js index dbad088a497d..d4b926156de1 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/lib/ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,8 @@ // MODULES // var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var accessors = require( './accessors.js' ); // MAIN // @@ -29,9 +31,9 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * Calculates the range of a strided array via a callback function. * * @param {PositiveInteger} N - number of indexed elements -* @param {Collection} x - input array/collection -* @param {integer} stride - index increment -* @param {NonNegativeInteger} offset - starting index +* @param {NumericArray|Collection|AccessorArrayLike} x - input array/collection +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index * @param {Callback} clbk - callback * @param {*} [thisArg] - execution context * @returns {number} range @@ -40,36 +42,44 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ]; * * function accessor( v ) { -* return v * 2.0; +* if ( v === void 0 ) { +* return; +* } +* return v * 2.0; * } * * var v = rangeBy( x.length, x, 1, 0, accessor ); * // returns 18.0 */ -function rangeBy( N, x, stride, offset, clbk, thisArg ) { +function rangeBy( N, x, strideX, offsetX, clbk, thisArg ) { var max; var min; var ix; var v; var i; + var o; if ( N <= 0 ) { return NaN; } - if ( N === 1 || stride === 0 ) { + o = arraylike2object( x ); + if ( o.accessorProtocol ) { + return accessors( N, o, strideX, offsetX, clbk, thisArg ); + } + if ( N === 1 || strideX === 0 ) { v = clbk.call( thisArg, x[ 0 ], 0, 0, x ); if ( v === void 0 || isnan( v ) ) { return NaN; } return 0.0; } - ix = offset; + ix = offsetX; for ( i = 0; i < N; i++ ) { min = clbk.call( thisArg, x[ ix ], i, ix, x ); if ( min !== void 0 ) { break; } - ix += stride; + ix += strideX; } if ( i === N ) { return NaN; @@ -77,7 +87,7 @@ function rangeBy( N, x, stride, offset, clbk, thisArg ) { max = min; i += 1; for ( i; i < N; i++ ) { - ix += stride; + ix += strideX; v = clbk.call( thisArg, x[ ix ], i, ix, x ); if ( v === void 0 ) { continue; diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/range_by.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/range_by.js index b4c87ca8271c..cb374ab0c995 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/lib/range_by.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/lib/range_by.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,8 @@ // MODULES // -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); // MAIN // @@ -29,8 +30,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * Calculates the range of a strided array via a callback function. * * @param {PositiveInteger} N - number of indexed elements -* @param {Collection} x - input array/collection -* @param {integer} stride - index increment +* @param {NumericArray|Collection|AccessorArrayLike} x - input array/collection +* @param {integer} strideX - index increment * @param {Callback} clbk - callback * @param {*} [thisArg] - execution context * @returns {number} range @@ -39,62 +40,17 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ]; * * function accessor( v ) { -* return v * 2.0; +* if ( v === void 0 ) { +* return; +* } +* return v * 2.0; * } * * var v = rangeBy( x.length, x, 1, accessor ); * // returns 18.0 */ -function rangeBy( N, x, stride, clbk, thisArg ) { - var max; - var min; - var ix; - var v; - var i; - - if ( N <= 0 ) { - return NaN; - } - if ( N === 1 || stride === 0 ) { - v = clbk.call( thisArg, x[ 0 ], 0, 0, x ); - if ( v === void 0 || isnan( v ) ) { - return NaN; - } - return 0.0; - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - for ( i = 0; i < N; i++ ) { - min = clbk.call( thisArg, x[ ix ], i, ix, x ); - if ( min !== void 0 ) { - break; - } - ix += stride; - } - if ( i === N ) { - return NaN; - } - max = min; - i += 1; - for ( i; i < N; i++ ) { - ix += stride; - v = clbk.call( thisArg, x[ ix ], i, ix, x ); - if ( v === void 0 ) { - continue; - } - if ( isnan( v ) ) { - return v; - } - if ( v < min ) { - min = v; - } else if ( v > max ) { - max = v; - } - } - return max - min; +function rangeBy( N, x, strideX, clbk, thisArg ) { + return ndarray(N, x, strideX, stride2offset(N, strideX), clbk, thisArg); } diff --git a/lib/node_modules/@stdlib/stats/base/range-by/test/test.js b/lib/node_modules/@stdlib/stats/base/range-by/test/test.js index a3de23413280..4bcd38aee8a9 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/range-by/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/range-by/test/test.ndarray.js index 4dfd226b7998..73355c48008d 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/test/test.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ var tape = require( 'tape' ); var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var rangeBy = require( './../lib/ndarray.js' ); @@ -53,6 +54,7 @@ tape( 'the function has an arity of 6', function test( t ) { tape( 'the function calculates the range of a strided array via a callback function', function test( t ) { var x; var v; + var i; x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; v = rangeBy( x.length, x, 1, 0, accessor ); @@ -74,11 +76,17 @@ tape( 'the function calculates the range of a strided array via a callback funct v = rangeBy( x.length, x, 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // sparse array + x = []; + for (i = 0; i < 5; i++) { + x.push(undefined); + } v = rangeBy( x.length, x, 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // sparse array + x = []; + for (i = 0; i < 5; i++) { + x.push(undefined); + } x[ 2 ] = 1.0; v = rangeBy( x.length, x, 1, 0, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); @@ -86,6 +94,49 @@ tape( 'the function calculates the range of a strided array via a callback funct t.end(); }); +tape( 'the function calculates the range of a strided array via a callback function (accessors)', function test( t ) { + var x; + var v; + var i; + + x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; + v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + t.strictEqual( v, 18.0, 'returns expected value' ); + + x = [ -4.0, -5.0 ]; + v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = [ -0.0, 0.0, -0.0 ]; + v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + x = [ NaN ]; + v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ NaN, NaN ]; + v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = []; + for (i = 0; i < 5; i++) { + x.push(undefined); + } + v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = []; + for (i = 0; i < 5; i++) { + x.push(undefined); + } + x[ 2 ] = 1.0; + v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) { var x; var v; @@ -104,13 +155,17 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', function test( t ) { var x; var v; + var i; x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; v = rangeBy( 1, x, 1, 0, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); - x = new Array( 1 ); // sparse array + x = []; + for (i = 0; i < 1; i++) { + x.push(undefined); + } v = rangeBy( 1, x, 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); @@ -167,13 +222,16 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', function test( t ) { var x; var v; - + var i; x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; v = rangeBy( x.length, x, 0, 0, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); - x = new Array( 1 ); // sparse array + x = []; + for (i = 0; i < 1; i++) { + x.push(undefined); + } v = rangeBy( 1, x, 0, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js b/lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js index aa3a295b2547..f030c3d0abec 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,8 @@ var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var Float64Array = require( '@stdlib/array/float64' ); -var rangeBy = require( './../lib/range_by.js' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var rangeBy = require( './../lib/main.js' ); // FUNCTIONS // @@ -54,6 +55,7 @@ tape( 'the function has an arity of 5', function test( t ) { tape( 'the function calculates the range of a strided array via a callback function', function test( t ) { var x; var v; + var i; x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; v = rangeBy( x.length, x, 1, accessor ); @@ -75,11 +77,17 @@ tape( 'the function calculates the range of a strided array via a callback funct v = rangeBy( x.length, x, 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // sparse array + x = []; + for (i = 0; i < 5; i++) { + x.push(undefined); + } v = rangeBy( x.length, x, 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // sparse array + x = []; + for (i = 0; i < 5; i++) { + x.push(undefined); + } x[ 2 ] = 1.0; v = rangeBy( x.length, x, 1, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); @@ -87,6 +95,49 @@ tape( 'the function calculates the range of a strided array via a callback funct t.end(); }); +tape( 'the function calculates the range of a strided array via a callback function (accessors)', function test( t ) { + var x; + var v; + var i; + + x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; + v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + t.strictEqual( v, 18.0, 'returns expected value' ); + + x = [ -4.0, -5.0 ]; + v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = [ -0.0, 0.0, -0.0 ]; + v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + x = [ NaN ]; + v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ NaN, NaN ]; + v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = []; + for (i = 0; i < 5; i++) { + x.push(undefined); // Explicitly adding `undefined` + } + v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = []; + for (i = 0; i < 5; i++) { + x.push(undefined); // Explicitly adding `undefined` + } + x[ 2 ] = 1.0; + v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) { var x; var v; @@ -105,13 +156,17 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', function test( t ) { var x; var v; + var i; x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; v = rangeBy( 1, x, 1, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); - x = new Array( 1 ); // sparse array + x = []; + for (i = 0; i < 1; i++) { + x.push(undefined); // Explicitly adding `undefined` + } v = rangeBy( 1, x, 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); @@ -168,13 +223,17 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', function test( t ) { var x; var v; + var i; x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; v = rangeBy( x.length, x, 0, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); - x = new Array( 1 ); // sparse array + x = []; + for (i = 0; i < 1; i++) { + x.push(undefined); + } v = rangeBy( 1, x, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); From fca8e7bc6a71850fbf265cb5ac496e8a85c17a98 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Fri, 4 Jul 2025 06:21:05 +0000 Subject: [PATCH 2/9] chore: update docs, test, 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: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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: 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: passed - task: lint_license_headers status: passed --- --- .../@stdlib/stats/base/range-by/README.md | 33 ++- .../base/range-by/benchmark/benchmark.js | 2 +- .../range-by/benchmark/benchmark.ndarray.js | 19 +- .../@stdlib/stats/base/range-by/docs/repl.txt | 28 ++- .../stats/base/range-by/docs/types/index.d.ts | 20 +- .../stats/base/range-by/docs/types/test.ts | 10 +- .../stats/base/range-by/examples/index.js | 9 +- .../stats/base/range-by/lib/accessors.js | 27 +-- .../@stdlib/stats/base/range-by/lib/index.js | 11 +- .../@stdlib/stats/base/range-by/lib/main.js | 29 ++- .../stats/base/range-by/lib/ndarray.js | 15 +- .../stats/base/range-by/lib/range_by.js | 59 ------ .../@stdlib/stats/base/range-by/test/test.js | 2 +- .../stats/base/range-by/test/test.ndarray.js | 189 +++++++++++++---- .../stats/base/range-by/test/test.range_by.js | 199 +++++++++++++----- 15 files changed, 413 insertions(+), 239 deletions(-) delete mode 100644 lib/node_modules/@stdlib/stats/base/range-by/lib/range_by.js diff --git a/lib/node_modules/@stdlib/stats/base/range-by/README.md b/lib/node_modules/@stdlib/stats/base/range-by/README.md index 3ce2e4defcf2..cf5007ffb5f7 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/README.md +++ b/lib/node_modules/@stdlib/stats/base/range-by/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2025 The Stdlib Authors. +Copyright (c) 2020 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ var rangeBy = require( '@stdlib/stats/base/range-by' ); #### rangeBy( N, x, strideX, clbk\[, thisArg] ) -Calculates the [range][range] of strided array `x` via a callback function. +Computes the [range][range] of a strided array via a callback function. ```javascript function accessor( v ) { @@ -89,19 +89,16 @@ var cnt = context.count; // returns 8 ``` -The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. For example, to access every other element +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element ```javascript -var floor = require( '@stdlib/math/base/special/floor' ); - function accessor( v ) { return v * 2.0; } var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ]; -var N = floor( x.length / 2 ); -var v = rangeBy( N, x, 2, accessor ); +var v = rangeBy( 4, x, 2, accessor ); // returns 12.0 ``` @@ -109,7 +106,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); function accessor( v ) { return v * 2.0; @@ -120,16 +116,15 @@ var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); // Create an offset view... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length/2 ); // Access every other element... -var v = rangeBy( N, x1, 2, accessor ); +var v = rangeBy( 3, x1, 2, accessor ); // returns 8.0 ``` -#### rangeBy.ndarray( N, x, strideX, offset, clbk\[, thisArg] ) +#### rangeBy.ndarray( N, x, strideX, offsetX, clbk\[, thisArg] ) -Calculates the [range][range] of strided array `x` via a callback function and using alternative indexing semantics. +Computes the [range][range] of a strided array via a callback function and using alternative indexing semantics. ```javascript function accessor( v ) { @@ -144,9 +139,9 @@ var v = rangeBy.ndarray( x.length, x, 1, 0, accessor ); The function has the following additional parameters: -- **offset**: starting index. +- **offsetX**: starting index. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x` +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x` ```javascript function accessor( v ) { @@ -170,6 +165,7 @@ var v = rangeBy.ndarray( 3, x, 1, x.length-3, accessor ); - If `N <= 0`, both functions return `NaN`. - A provided callback function should return a numeric value. - If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is **ignored**. +- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). - When possible, prefer using [`drange`][@stdlib/stats/strided/drange], [`srange`][@stdlib/stats/strided/srange], and/or [`range`][@stdlib/stats/base/range], as, depending on the environment, these interfaces are likely to be significantly more performant. @@ -183,15 +179,16 @@ var v = rangeBy.ndarray( 3, x, 1, x.length-3, accessor ); ```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filledarrayBy = require( '@stdlib/array/filled-by' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var rangeBy = require( '@stdlib/stats/base/range-by' ); function accessor( v ) { return v * 2.0; } -var x = filledarrayBy( 10, 'float64', discreteUniform( -50, 50 ) ); +var x = discreteUniform( 10, -50, 50, { + 'dtype': 'float64' +}); console.log( x ); var v = rangeBy( x.length, x, 1, accessor ); @@ -231,6 +228,8 @@ console.log( v ); [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray +[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor + [@stdlib/stats/strided/drange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/drange diff --git a/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.js index 5e2a32839092..d29e87925f27 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.ndarray.js index 53ddf8c546cf..7fcc4c339195 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,13 +21,20 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; var rangeBy = require( './../lib/ndarray.js' ); +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + // FUNCTIONS // /** @@ -49,13 +56,7 @@ function accessor( value ) { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( ( randu()*20.0 ) - 10.0 ); - } + var x = uniform( len, -10, 10, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/range-by/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range-by/docs/repl.txt index fc3445e704d6..a8fbaef83d61 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range-by/docs/repl.txt @@ -1,8 +1,9 @@ + {{alias}}( N, x, strideX, clbk[, thisArg] ) - Calculates the range of a strided array via a callback function. + Computes the range of a strided array via a callback function. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + The `N` and stride parameters determine which elements in the strided array + are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use typed array views. @@ -13,7 +14,7 @@ - value: array element. - aidx: array index. - - sidx: strided index (offsetX + aidx*strideX). + - sidx: strided index (offset + aidx*stride). - array: the input array. The callback function should return a numeric value. @@ -31,7 +32,7 @@ like (excluding strings and functions). strideX: integer - Index increment for `x`. + Stride length. clbk: Function Callback function. @@ -52,17 +53,15 @@ > {{alias}}( x.length, x, 1, accessor ) 18.0 - // Using `N` and `strideX` parameters: + // Using `N` and stride parameters: > x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}( N, x, 2, accessor ) + > {{alias}}( 3, x, 2, accessor ) 12.0 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > {{alias}}( N, x1, 2, accessor ) + > {{alias}}( 3, x1, 2, accessor ) 8.0 @@ -71,7 +70,7 @@ alternative indexing semantics. While typed array views mandate a view offset based on the underlying - buffer, the `offsetX` parameter supports indexing semantics based on a + buffer, the offset parameter supports indexing semantics based on a starting index. Parameters @@ -84,10 +83,10 @@ like (excluding strings and functions). strideX: integer - Index increment for `x`. + Stride length. offsetX: integer - Starting index of `x`. + Starting index. clbk: Function Callback function. @@ -110,8 +109,7 @@ // Using an index offset: > x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1, accessor ) + > {{alias}}.ndarray( 3, x, 2, 1, accessor ) 8.0 See Also diff --git a/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts index 3de76051c8b1..870bf7b81c6b 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +20,8 @@ /// -// import { Collection } from '@stdlib/types/array'; import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; - /** * Input array. */ @@ -72,7 +70,7 @@ type Ternary = ( this: U, value: T, aidx: number, sidx: number ) => number * @param array - input array * @returns accessed value */ -type Quaternary = ( this: U, value: T, aidx: number, sidx: number, array: InputArray ) => number | void; +type Quaternary = ( this: U, value: T, aidx: number, sidx: number, array: Collection ) => number | void; /** * Returns an accessed value. @@ -90,7 +88,7 @@ type Callback = Nullary | Unary | Binary | Ternary | */ interface Routine { /** - * Calculates the range of a strided array via a callback function. + * Computes the range of a strided array via a callback function. * * ## Notes * @@ -120,10 +118,10 @@ interface Routine { * var v = rangeBy( x.length, x, 1, accessor ); * // returns 18.0 */ - ( N: number, x: InputArray, stride: number, clbk: Callback, thisArg?: ThisParameterType> ): number; + ( N: number, x: InputArray, strideX: number, clbk: Callback, thisArg?: ThisParameterType> ): number; /** - * Calculates the range of a strided array via a callback function and using alternative indexing semantics. + * Computes the range of a strided array via a callback function and using alternative indexing semantics. * * ## Notes * @@ -138,8 +136,8 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array - * @param stride - stride length - * @param offset - starting index + * @param strideX - stride length + * @param offsetX - starting index * @param clbk - callback * @param thisArg - execution context * @returns range @@ -154,7 +152,7 @@ interface Routine { * var v = rangeBy.ndarray( x.length, x, 1, 0, accessor ); * // returns 18.0 */ - ndarray( N: number, x: InputArray, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): number; + ndarray( N: number, x: InputArray, strideX: number, offsetX: number, clbk: Callback, thisArg?: ThisParameterType> ): number; } /** @@ -173,7 +171,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array -* @param stride - stride length +* @param strideX - stride length * @param clbk - callback * @param thisArg - execution context * @returns range diff --git a/lib/node_modules/@stdlib/stats/base/range-by/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/range-by/docs/types/test.ts index dff4896a2488..20154cdde8d2 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/range-by/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ * limitations under the License. */ -import rangeBy = require( '@stdlib/stats/base/range-by' ); import AccessorArray = require( '@stdlib/array/base/accessor' ); +import rangeBy = require( './index' ); const accessor = (): number => { return 5.0; @@ -31,8 +31,9 @@ const accessor = (): number => { const x = new Float64Array( 10 ); rangeBy( x.length, x, 1, accessor ); // $ExpectType number - rangeBy( x.length, x, 1, accessor, {} ); // $ExpectType number rangeBy( x.length, new AccessorArray ( x ), 1, accessor ); // $ExpectType number + + rangeBy( x.length, x, 1, accessor, {} ); // $ExpectType number rangeBy( x.length, new AccessorArray ( x ), 1, accessor, {} ); // $ExpectType number } @@ -105,8 +106,9 @@ const accessor = (): number => { const x = new Float64Array( 10 ); rangeBy.ndarray( x.length, x, 1, 0, accessor ); // $ExpectType number - rangeBy.ndarray( x.length, x, 1, 0, accessor, {} ); // $ExpectType number rangeBy.ndarray( x.length, new AccessorArray ( x ), 1, 0, accessor ); // $ExpectType number + + rangeBy.ndarray( x.length, x, 1, 0, accessor, {} ); // $ExpectType number rangeBy.ndarray( x.length, new AccessorArray ( x ), 1, 0, accessor, {} ); // $ExpectType number } diff --git a/lib/node_modules/@stdlib/stats/base/range-by/examples/index.js b/lib/node_modules/@stdlib/stats/base/range-by/examples/index.js index c2cae6048cd5..91cb5a8d1c92 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,15 +18,16 @@ 'use strict'; -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filledarrayBy = require( '@stdlib/array/filled-by' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var rangeBy = require( './../lib' ); function accessor( v ) { return v * 2.0; } -var x = filledarrayBy( 10, 'float64', discreteUniform( -50, 50 ) ); +var x = discreteUniform( 10, -50, 50, { + 'dtype': 'float64' +}); console.log( x ); var v = rangeBy( x.length, x, 1, accessor ); diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/accessors.js index ca5c6b182781..d9f95e3aa0d6 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/lib/accessors.js @@ -26,29 +26,29 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); // MAIN // /** -* Calculates the range of a strided array via a callback function. +* Computes the range of a strided array via a callback function. * * @param {PositiveInteger} N - number of indexed elements -* @param {NumericArray|Collection|AccessorArrayLike} x - input array/collection -* @param {integer} strideX - stride length for `x` +* @param {Object} x - input array object +* @param {Collection} x.data - input array data +* @param {Array} x.accessors - array element accessors +* @param {integer} strideX - stride length * @param {NonNegativeInteger} offsetX - starting index * @param {Callback} clbk - callback * @param {*} [thisArg] - execution context * @returns {number} range * * @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); * -* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ]; +* var x = toAccessorArray( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); * * function accessor( v ) { -* if ( v === void 0 ) { -* return; -* } -* return v * 2.0; +* return v * 2.0; * } * -* var v = rangeBy( x.length, arraylike2object(x), 1, 0, accessor ); +* var v = rangeBy( x.length, arraylike2object( x ), 1, 0, accessor ); * // returns 18.0 */ function rangeBy( N, x, strideX, offsetX, clbk, thisArg) { @@ -60,21 +60,22 @@ function rangeBy( N, x, strideX, offsetX, clbk, thisArg) { var v; var i; + // Cache reference to array data: xbuf = x.data; + // Cache a reference to the element accessor: get = x.accessors[ 0 ]; if ( N === 1 || strideX === 0 ) { - v = clbk.call( thisArg, get(xbuf, offsetX), 0, 0, x ); + v = clbk.call( thisArg, get( xbuf, offsetX ), 0, offsetX, x ); if ( v === void 0 || isnan( v ) ) { return NaN; } return 0.0; } - ix = offsetX; for ( i = 0; i < N; i++ ) { - min = clbk.call( thisArg, get(xbuf, ix), i, ix, x ); + min = clbk.call( thisArg, get( xbuf, ix ), i, ix, x ); if ( min !== void 0 ) { break; } @@ -87,7 +88,7 @@ function rangeBy( N, x, strideX, offsetX, clbk, thisArg) { i += 1; for ( i; i < N; i++ ) { ix += strideX; - v = clbk.call( thisArg, get(xbuf, ix), i, ix, x ); + v = clbk.call( thisArg, get( xbuf, ix ), i, ix, x ); if ( v === void 0 ) { continue; } diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/index.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/index.js index e10d23e20836..be82110978f0 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ 'use strict'; /** -* Calculate the range of a strided array via a callback function. +* Compute the range of a strided array via a callback function. * * @module @stdlib/stats/base/range-by * @@ -50,7 +50,14 @@ // MODULES // +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); var main = require( './main.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( main, 'ndarray', ndarray ); // EXPORTS // diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js index 14a623095f81..696535445794 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,14 +20,35 @@ // MODULES // -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var rangeBy = require( './range_by.js' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); var ndarray = require( './ndarray.js' ); // MAIN // -setReadOnly( rangeBy, 'ndarray', ndarray ); +/** +* Computes the range of a strided array via a callback function. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {NumericArray|Collection|AccessorArrayLike} x - input array/collection +* @param {integer} strideX - index increment +* @param {Callback} clbk - callback +* @param {*} [thisArg] - execution context +* @returns {number} range +* +* @example +* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ]; +* +* function accessor( v ) { +* return v * 2.0; +* } +* +* var v = rangeBy( x.length, x, 1, accessor ); +* // returns 18.0 +*/ +function rangeBy( N, x, strideX, clbk, thisArg ) { + return ndarray(N, x, strideX, stride2offset(N, strideX), clbk, thisArg); +} // EXPORTS // diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/ndarray.js index d4b926156de1..d2ed8a090aa2 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/lib/ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,11 +28,11 @@ var accessors = require( './accessors.js' ); // MAIN // /** -* Calculates the range of a strided array via a callback function. +* Computes the range of a strided array via a callback function. * * @param {PositiveInteger} N - number of indexed elements -* @param {NumericArray|Collection|AccessorArrayLike} x - input array/collection -* @param {integer} strideX - stride length for `x` +* @param {Collection} x - input array/collection +* @param {integer} strideX - stride length * @param {NonNegativeInteger} offsetX - starting index * @param {Callback} clbk - callback * @param {*} [thisArg] - execution context @@ -42,10 +42,7 @@ var accessors = require( './accessors.js' ); * var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ]; * * function accessor( v ) { -* if ( v === void 0 ) { -* return; -* } -* return v * 2.0; +* return v * 2.0; * } * * var v = rangeBy( x.length, x, 1, 0, accessor ); @@ -67,7 +64,7 @@ function rangeBy( N, x, strideX, offsetX, clbk, thisArg ) { return accessors( N, o, strideX, offsetX, clbk, thisArg ); } if ( N === 1 || strideX === 0 ) { - v = clbk.call( thisArg, x[ 0 ], 0, 0, x ); + v = clbk.call( thisArg, x[ offsetX ], 0, offsetX, x ); if ( v === void 0 || isnan( v ) ) { return NaN; } diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/range_by.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/range_by.js deleted file mode 100644 index cb374ab0c995..000000000000 --- a/lib/node_modules/@stdlib/stats/base/range-by/lib/range_by.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var stride2offset = require( '@stdlib/strided/base/stride2offset' ); -var ndarray = require( './ndarray.js' ); - - -// MAIN // - -/** -* Calculates the range of a strided array via a callback function. -* -* @param {PositiveInteger} N - number of indexed elements -* @param {NumericArray|Collection|AccessorArrayLike} x - input array/collection -* @param {integer} strideX - index increment -* @param {Callback} clbk - callback -* @param {*} [thisArg] - execution context -* @returns {number} range -* -* @example -* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ]; -* -* function accessor( v ) { -* if ( v === void 0 ) { -* return; -* } -* return v * 2.0; -* } -* -* var v = rangeBy( x.length, x, 1, accessor ); -* // returns 18.0 -*/ -function rangeBy( N, x, strideX, clbk, thisArg ) { - return ndarray(N, x, strideX, stride2offset(N, strideX), clbk, thisArg); -} - - -// EXPORTS // - -module.exports = rangeBy; diff --git a/lib/node_modules/@stdlib/stats/base/range-by/test/test.js b/lib/node_modules/@stdlib/stats/base/range-by/test/test.js index 4bcd38aee8a9..a3de23413280 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/range-by/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/range-by/test/test.ndarray.js index 73355c48008d..e77995c7c7aa 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/test/test.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); @@ -54,7 +53,6 @@ tape( 'the function has an arity of 6', function test( t ) { tape( 'the function calculates the range of a strided array via a callback function', function test( t ) { var x; var v; - var i; x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; v = rangeBy( x.length, x, 1, 0, accessor ); @@ -76,17 +74,11 @@ tape( 'the function calculates the range of a strided array via a callback funct v = rangeBy( x.length, x, 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = []; - for (i = 0; i < 5; i++) { - x.push(undefined); - } + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array v = rangeBy( x.length, x, 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = []; - for (i = 0; i < 5; i++) { - x.push(undefined); - } + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array x[ 2 ] = 1.0; v = rangeBy( x.length, x, 1, 0, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); @@ -97,41 +89,34 @@ tape( 'the function calculates the range of a strided array via a callback funct tape( 'the function calculates the range of a strided array via a callback function (accessors)', function test( t ) { var x; var v; - var i; x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; - v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + v = rangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); t.strictEqual( v, 18.0, 'returns expected value' ); x = [ -4.0, -5.0 ]; - v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + v = rangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); x = [ -0.0, 0.0, -0.0 ]; - v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + v = rangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); x = [ NaN ]; - v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + v = rangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); x = [ NaN, NaN ]; - v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + v = rangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = []; - for (i = 0; i < 5; i++) { - x.push(undefined); - } - v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array + v = rangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = []; - for (i = 0; i < 5; i++) { - x.push(undefined); - } + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array x[ 2 ] = 1.0; - v = rangeBy( x.length, toAccessorArray(x), 1, 0, accessor ); + v = rangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); t.end(); @@ -152,20 +137,31 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = rangeBy( 0, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = rangeBy( -1, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', function test( t ) { var x; var v; - var i; x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; v = rangeBy( 1, x, 1, 0, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); - x = []; - for (i = 0; i < 1; i++) { - x.push(undefined); - } + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array v = rangeBy( 1, x, 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); @@ -173,8 +169,24 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', fun t.end(); }); +tape( 'if provided an `N` parameter equal to `1`, the function returns `0` (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = rangeBy( 1, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + + v = rangeBy( 1, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -189,15 +201,34 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]; - N = floor( x.length / 2 ); - v = rangeBy( N, x, 2, 0, accessor ); + v = rangeBy( 4, x, 2, 0, accessor ); + + t.strictEqual( v, 12.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `stride` parameter (accessors)', function test( t ) { + var x; + var v; + + x = [ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0 + ]; + + v = rangeBy( 4, toAccessorArray( x ), 2, 0, accessor ); t.strictEqual( v, 12.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -212,8 +243,28 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - N = floor( x.length / 2 ); - v = rangeBy( N, x, -2, 6, accessor ); + v = rangeBy( 4, x, -2, 6, accessor ); + + t.strictEqual( v, 12.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) { + var x; + var v; + + x = [ + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + -2.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ]; + + v = rangeBy( 4, toAccessorArray( x ), -2, 6, accessor ); t.strictEqual( v, 12.0, 'returns expected value' ); t.end(); @@ -222,16 +273,13 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', function test( t ) { var x; var v; - var i; + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; v = rangeBy( x.length, x, 0, 0, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); - x = []; - for (i = 0; i < 1; i++) { - x.push(undefined); - } + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array v = rangeBy( 1, x, 0, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); @@ -239,6 +287,23 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', t.end(); }); +tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = rangeBy( x.length, toAccessorArray( x ), 0, 0, accessor ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + + v = rangeBy( 1, toAccessorArray( x ), 0, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports an offset parameter', function test( t ) { var x; var v; @@ -258,6 +323,25 @@ tape( 'the function supports an offset parameter', function test( t ) { t.end(); }); +tape( 'the function supports an offset parameter (accessors)', function test( t ) { + var x; + var v; + + x = [ + 1.0, + -2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + -6.0 // 2 + ]; + + v = rangeBy( 3, toAccessorArray( x ), 2, 1, accessor ); + t.strictEqual( v, 20.0, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports providing a callback execution context', function test( t ) { var ctx; var x; @@ -276,3 +360,22 @@ tape( 'the function supports providing a callback execution context', function t return v * 2.0; } }); + +tape( 'the function supports providing a callback execution context (accessors)', function test( t ) { + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + rangeBy( x.length, toAccessorArray( x ), 1, 0, accessor, ctx ); + + t.strictEqual( ctx.count, x.length, 'returns expected value' ); + t.end(); + + function accessor( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v * 2.0; + } +}); diff --git a/lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js b/lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js index f030c3d0abec..77e1fd90cf41 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,11 +21,10 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); -var Float64Array = require( '@stdlib/array/float64' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var Float64Array = require( '@stdlib/array/float64' ); var rangeBy = require( './../lib/main.js' ); @@ -55,7 +54,6 @@ tape( 'the function has an arity of 5', function test( t ) { tape( 'the function calculates the range of a strided array via a callback function', function test( t ) { var x; var v; - var i; x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; v = rangeBy( x.length, x, 1, accessor ); @@ -77,17 +75,11 @@ tape( 'the function calculates the range of a strided array via a callback funct v = rangeBy( x.length, x, 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = []; - for (i = 0; i < 5; i++) { - x.push(undefined); - } + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array v = rangeBy( x.length, x, 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = []; - for (i = 0; i < 5; i++) { - x.push(undefined); - } + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array x[ 2 ] = 1.0; v = rangeBy( x.length, x, 1, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); @@ -98,41 +90,34 @@ tape( 'the function calculates the range of a strided array via a callback funct tape( 'the function calculates the range of a strided array via a callback function (accessors)', function test( t ) { var x; var v; - var i; x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; - v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + v = rangeBy( x.length, toAccessorArray( x ), 1, accessor ); t.strictEqual( v, 18.0, 'returns expected value' ); x = [ -4.0, -5.0 ]; - v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + v = rangeBy( x.length, toAccessorArray( x ), 1, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); x = [ -0.0, 0.0, -0.0 ]; - v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + v = rangeBy( x.length, toAccessorArray( x ), 1, accessor ); t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); x = [ NaN ]; - v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + v = rangeBy( x.length, toAccessorArray( x ), 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); x = [ NaN, NaN ]; - v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + v = rangeBy( x.length, toAccessorArray( x ), 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = []; - for (i = 0; i < 5; i++) { - x.push(undefined); // Explicitly adding `undefined` - } - v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array + v = rangeBy( x.length, toAccessorArray( x ), 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = []; - for (i = 0; i < 5; i++) { - x.push(undefined); // Explicitly adding `undefined` - } + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array x[ 2 ] = 1.0; - v = rangeBy( x.length, toAccessorArray(x), 1, accessor ); + v = rangeBy( x.length, toAccessorArray( x ), 1, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); t.end(); @@ -153,20 +138,31 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = rangeBy( 0, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = rangeBy( -1, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', function test( t ) { var x; var v; - var i; x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; v = rangeBy( 1, x, 1, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); - x = []; - for (i = 0; i < 1; i++) { - x.push(undefined); // Explicitly adding `undefined` - } + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array v = rangeBy( 1, x, 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); @@ -174,8 +170,24 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', fun t.end(); }); +tape( 'if provided an `N` parameter equal to `1`, the function returns `0` (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = rangeBy( 1, toAccessorArray( x ), 1, accessor ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + + v = rangeBy( 1, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -190,15 +202,34 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]; - N = floor( x.length / 2 ); - v = rangeBy( N, x, 2, accessor ); + v = rangeBy( 4, x, 2, accessor ); + + t.strictEqual( v, 12.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `stride` parameter (accessors)', function test( t ) { + var x; + var v; + + x = [ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0 + ]; + + v = rangeBy( 4, toAccessorArray( x ), 2, accessor ); t.strictEqual( v, 12.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -213,8 +244,27 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - N = floor( x.length / 2 ); - v = rangeBy( N, x, -2, accessor ); + v = rangeBy( 4, x, -2, accessor ); + + t.strictEqual( v, 12.0, 'returns expected value' ); + t.end(); +}); +tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) { + var x; + var v; + + x = [ + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + -2.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ]; + + v = rangeBy( 4, toAccessorArray( x ), -2, accessor ); t.strictEqual( v, 12.0, 'returns expected value' ); t.end(); @@ -223,17 +273,13 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', function test( t ) { var x; var v; - var i; x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; v = rangeBy( x.length, x, 0, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); - x = []; - for (i = 0; i < 1; i++) { - x.push(undefined); - } + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array v = rangeBy( 1, x, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); @@ -241,10 +287,26 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', t.end(); }); +tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = rangeBy( x.length, toAccessorArray( x ), 0, accessor ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + + v = rangeBy( 1, toAccessorArray( x ), 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -260,9 +322,33 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = rangeBy( N, x1, 2, accessor ); + v = rangeBy( 4, x1, 2, accessor ); + t.strictEqual( v, 12.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets (accessors)', function test( t ) { + var x0; + var x1; + var v; + + x0 = new Float64Array([ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0, // 3 + 6.0 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + + v = rangeBy( 4, toAccessorArray( x1 ), 2, accessor ); t.strictEqual( v, 12.0, 'returns expected value' ); t.end(); @@ -286,3 +372,22 @@ tape( 'the function supports providing a callback execution context', function t return v * 2.0; } }); + +tape( 'the function supports providing a callback execution context (accessors)', function test( t ) { + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + rangeBy( x.length, toAccessorArray( x ), 1, accessor, ctx ); + + t.strictEqual( ctx.count, x.length, 'returns expected value' ); + t.end(); + + function accessor( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v * 2.0; + } +}); From 7b13902888bf683b463faa9298e48b5a777fa709 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Fri, 4 Jul 2025 06:37:56 +0000 Subject: [PATCH 3/9] chore: update type --- 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: 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 --- --- .../@stdlib/stats/base/range-by/docs/types/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts index 870bf7b81c6b..5ca35ac3c6ba 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts @@ -103,7 +103,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array - * @param stride - stride length + * @param strideX - stride length * @param clbk - callback * @param thisArg - execution context * @returns range @@ -156,7 +156,7 @@ interface Routine { } /** -* Calculates the range of a strided array via a callback function. +* Computes the range of a strided array via a callback function. * * ## Notes * From 935d50a33e59fa3505100ff77a2e347d74f69705 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 4 Jul 2025 02:12:30 -0700 Subject: [PATCH 4/9] fix: ensure support for non-numeric input arrays Signed-off-by: Athan --- .../@stdlib/stats/base/range-by/docs/types/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts index 5ca35ac3c6ba..d27183de4d5c 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/range-by/docs/types/index.d.ts @@ -20,12 +20,12 @@ /// -import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; /** * Input array. */ -type InputArray = NumericArray | Collection | AccessorArrayLike; +type InputArray = Collection | AccessorArrayLike; /** * Returns an accessed value. @@ -118,7 +118,7 @@ interface Routine { * var v = rangeBy( x.length, x, 1, accessor ); * // returns 18.0 */ - ( N: number, x: InputArray, strideX: number, clbk: Callback, thisArg?: ThisParameterType> ): number; + ( N: number, x: InputArray, strideX: number, clbk: Callback, thisArg?: ThisParameterType> ): number; /** * Computes the range of a strided array via a callback function and using alternative indexing semantics. @@ -152,7 +152,7 @@ interface Routine { * var v = rangeBy.ndarray( x.length, x, 1, 0, accessor ); * // returns 18.0 */ - ndarray( N: number, x: InputArray, strideX: number, offsetX: number, clbk: Callback, thisArg?: ThisParameterType> ): number; + ndarray( N: number, x: InputArray, strideX: number, offsetX: number, clbk: Callback, thisArg?: ThisParameterType> ): number; } /** From 0632e20bf389ca7e39426b44ccbf1fd47a932e91 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 4 Jul 2025 02:16:58 -0700 Subject: [PATCH 5/9] docs: fix dtype and description Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/range-by/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js index 696535445794..68eae6dd99d4 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js @@ -30,7 +30,7 @@ var ndarray = require( './ndarray.js' ); * Computes the range of a strided array via a callback function. * * @param {PositiveInteger} N - number of indexed elements -* @param {NumericArray|Collection|AccessorArrayLike} x - input array/collection +* @param {Collection} x - input array * @param {integer} strideX - index increment * @param {Callback} clbk - callback * @param {*} [thisArg] - execution context From 64cd1578b26f1fa36165ee52a268776e9029b488 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 4 Jul 2025 02:17:25 -0700 Subject: [PATCH 6/9] style: fix spacing Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/range-by/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js index 68eae6dd99d4..c1a35bc4202f 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/lib/main.js @@ -47,7 +47,7 @@ var ndarray = require( './ndarray.js' ); * // returns 18.0 */ function rangeBy( N, x, strideX, clbk, thisArg ) { - return ndarray(N, x, strideX, stride2offset(N, strideX), clbk, thisArg); + return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg ); } From bc266e4dc71aea9570b86229bf17b5dc9ecdd746 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 4 Jul 2025 02:18:32 -0700 Subject: [PATCH 7/9] docs: update desc Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/range-by/lib/ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/ndarray.js index d2ed8a090aa2..a6d6bd627310 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/lib/ndarray.js @@ -31,7 +31,7 @@ var accessors = require( './accessors.js' ); * Computes the range of a strided array via a callback function. * * @param {PositiveInteger} N - number of indexed elements -* @param {Collection} x - input array/collection +* @param {Collection} x - input array * @param {integer} strideX - stride length * @param {NonNegativeInteger} offsetX - starting index * @param {Callback} clbk - callback From 905a2988570262d0bc42827fe2b92ec2c87971c7 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 4 Jul 2025 02:20:42 -0700 Subject: [PATCH 8/9] test: update import path Signed-off-by: Athan --- .../@stdlib/stats/base/range-by/test/test.range_by.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js b/lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js index 77e1fd90cf41..2f3f078803b1 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js @@ -25,7 +25,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var Float64Array = require( '@stdlib/array/float64' ); -var rangeBy = require( './../lib/main.js' ); +var rangeBy = require( './../lib' ); // FUNCTIONS // From 96209b7c90c69a4155f30c95a5db8ccdfb16406f Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 4 Jul 2025 02:22:08 -0700 Subject: [PATCH 9/9] test: rename file Signed-off-by: Athan --- .../stats/base/range-by/test/{test.range_by.js => test.main.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/node_modules/@stdlib/stats/base/range-by/test/{test.range_by.js => test.main.js} (100%) diff --git a/lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js b/lib/node_modules/@stdlib/stats/base/range-by/test/test.main.js similarity index 100% rename from lib/node_modules/@stdlib/stats/base/range-by/test/test.range_by.js rename to lib/node_modules/@stdlib/stats/base/range-by/test/test.main.js