From 6c83a27d77cac030e92d5203a1b8e03270300476 Mon Sep 17 00:00:00 2001 From: orthodox-64 Date: Tue, 23 Dec 2025 21:31:26 +0530 Subject: [PATCH 1/3] feat: add stats/strided/midrange-by --- .../stats/strided/midrange-by/README.md | 230 ++++++++++ .../midrange-by/benchmark/benchmark.js | 103 +++++ .../benchmark/benchmark.ndarray.js | 103 +++++ .../stats/strided/midrange-by/docs/repl.txt | 117 +++++ .../strided/midrange-by/docs/types/index.d.ts | 204 +++++++++ .../strided/midrange-by/docs/types/test.ts | 192 +++++++++ .../strided/midrange-by/examples/index.js | 34 ++ .../strided/midrange-by/lib/accessors.js | 115 +++++ .../stats/strided/midrange-by/lib/index.js | 67 +++ .../stats/strided/midrange-by/lib/main.js | 56 +++ .../stats/strided/midrange-by/lib/ndarray.js | 112 +++++ .../stats/strided/midrange-by/package.json | 69 +++ .../stats/strided/midrange-by/test/test.js | 38 ++ .../strided/midrange-by/test/test.main.js | 398 ++++++++++++++++++ .../strided/midrange-by/test/test.ndarray.js | 381 +++++++++++++++++ 15 files changed, 2219 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/README.md create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/lib/accessors.js create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/package.json create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/test/test.js create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/test/test.main.js create mode 100644 lib/node_modules/@stdlib/stats/strided/midrange-by/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/README.md b/lib/node_modules/@stdlib/stats/strided/midrange-by/README.md new file mode 100644 index 000000000000..63cb2af6ba65 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/README.md @@ -0,0 +1,230 @@ + + +# midrangeBy + +> Calculate the [mid-range][mid-range] of a strided array via a callback function. + +
+ +The [**mid-range**][mid-range], or **mid-extreme**, is the arithmetic mean of the maximum and minimum values in a data set. The measure is the midpoint of the range and a measure of central tendency. + +
+ + + +
+ +## Usage + +```javascript +var midrangeBy = require( '@stdlib/stats/strided/midrange-by' ); +``` + +#### midrangeBy( N, x, strideX, clbk\[, thisArg] ) + +Computes the [mid-range][mid-range] of a strided array via a callback function. + +```javascript +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 v = midrangeBy( x.length, x, 1, accessor ); +// returns -1.0 +``` + +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). +- **strideX**: stride length. +- **clbk**: callback function. +- **thisArg**: execution context (_optional_). + +The invoked callback is provided four arguments: + +- **value**: array element. +- **aidx**: array index. +- **sidx**: strided index (`offset + aidx*stride`). +- **array**: input array/collection. + +To set the callback execution context, provide a `thisArg`. + +```javascript +function accessor( v ) { + this.count += 1; + return v * 2.0; +} + +var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ]; + +var context = { + 'count': 0 +}; + +var v = midrangeBy( x.length, x, 1, accessor, context ); +// returns -1.0 + +var cnt = context.count; +// returns 8 +``` + +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element + +```javascript +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 v = midrangeBy( 4, x, 2, accessor ); +// returns 2.0 +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +function accessor( v ) { + return v * 2.0; +} + +// Initial array... +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 + +// Access every other element... +var v = midrangeBy( 3, x1, 2, accessor ); +// returns -8.0 +``` + +#### midrangeBy.ndarray( N, x, strideX, offsetX, clbk\[, thisArg] ) + +Computes the [mid-range][mid-range] of a strided array via a callback function and using alternative indexing semantics. + +```javascript +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 v = midrangeBy.ndarray( x.length, x, 1, 0, accessor ); +// returns -1.0 +``` + +The function has the following additional parameters: + +- **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` + +```javascript +function accessor( v ) { + return v * 2.0; +} + +var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ]; + +var v = midrangeBy.ndarray( 3, x, 1, x.length-3, accessor ); +// returns -1.0 +``` + +
+ + + +
+ +## Notes + +- 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 [`midrange`][@stdlib/stats/strided/midrange], as, depending on the environment, it is likely to be significantly more performant. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var midrangeBy = require( '@stdlib/stats/strided/midrange-by' ); + +function accessor( v ) { + return v * 2.0; +} + +var x = discreteUniform( 10, -50, 50, { + 'dtype': 'float64' +}); +console.log( x ); + +var v = midrangeBy( x.length, x, 1, accessor ); +console.log( v ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/strided/midrange-by/benchmark/benchmark.js new file mode 100644 index 000000000000..4d1bc7e4c47e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/benchmark/benchmark.js @@ -0,0 +1,103 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var midrangeBy = require( './../lib/main.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Accessor function. +* +* @private +* @param {number} value - array element +* @returns {number} accessed value +*/ +function accessor( value ) { + return value * 2.0; +} + +/** +* Create a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len, -10, 10, options ); + return benchmark; + + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = midrangeBy( x.length, x, 1, accessor ); + if ( isnan( v ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( v ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/strided/midrange-by/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..d2e9c6792810 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/benchmark/benchmark.ndarray.js @@ -0,0 +1,103 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var midrangeBy = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Accessor function. +* +* @private +* @param {number} value - array element +* @returns {number} accessed value +*/ +function accessor( value ) { + return value * 2.0; +} + +/** +* Create a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len, -10, 10, options ); + return benchmark; + + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = midrangeBy( x.length, x, 1, 0, accessor ); + if ( isnan( v ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( v ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/repl.txt b/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/repl.txt new file mode 100644 index 000000000000..079a1bcfd7f1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/repl.txt @@ -0,0 +1,117 @@ + +{{alias}}( N, x, strideX, clbk[, thisArg] ) + Computes the mid-range of a strided array via a callback function. + + 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. + + If `N <= 0`, the function returns `NaN`. + + The callback function is provided four arguments: + + - value: array element. + - aidx: array index. + - sidx: strided index (offset + aidx*stride). + - array: the input array. + + The callback function should return a numeric value. + + If the callback function does not return any value (or equivalently, + explicitly returns `undefined`), the value is ignored. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: Array|TypedArray|Object + Input array/collection. If provided an object, the object must be array- + like (excluding strings and functions). + + strideX: integer + Stride length. + + clbk: Function + Callback function. + + thisArg: any (optional) + Execution context. + + Returns + ------- + out: number + Mid-range. + + Examples + -------- + // Standard Usage: + > function accessor( v ) { return v * 2.0; }; + > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; + > {{alias}}( x.length, x, 1, accessor ) + -1.0 + + // Using `N` and stride parameters: + > x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; + > {{alias}}( 3, x, 2, accessor ) + 2.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 ); + > {{alias}}( 3, x1, 2, accessor ) + -8.0 + + +{{alias}}.ndarray( N, x, strideX, offsetX, clbk[, thisArg] ) + Calculates the mid-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 + starting index. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: Array|TypedArray|Object + Input array/collection. If provided an object, the object must be array- + like (excluding strings and functions). + + strideX: integer + Stride length. + + offsetX: integer + Starting index. + + clbk: Function + Callback function. + + thisArg: any (optional) + Execution context. + + Returns + ------- + out: number + Mid-range. + + Examples + -------- + // Standard Usage: + > function accessor( v ) { return v * 2.0; }; + > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; + > {{alias}}.ndarray( x.length, x, 1, 0, accessor ) + -1.0 + + // Using an index offset: + > x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ]; + > {{alias}}.ndarray( 3, x, 2, 1, accessor ) + -8.0 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/types/index.d.ts new file mode 100644 index 000000000000..0e51b2d173e2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/types/index.d.ts @@ -0,0 +1,204 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; + +/** +* Input array. +*/ +type InputArray = Collection | AccessorArrayLike; + +/** +* Returns an accessed value. +* +* @returns accessed value +*/ +type Nullary = ( this: U ) => number | void; + +/** +* Returns an accessed value. +* +* @param value - array element +* @returns accessed value +*/ +type Unary = ( this: U, value: T ) => number | void; + +/** +* Returns an accessed value. +* +* @param value - array element +* @param aidx - array index +* @returns accessed value +*/ +type Binary = ( this: U, value: T, aidx: number ) => number | void; + +/** +* Returns an accessed value. +* +* @param value - array element +* @param aidx - array index +* @param sidx - strided index (offset + aidx*stride) +* @returns accessed value +*/ +type Ternary = ( this: U, value: T, aidx: number, sidx: number ) => number | void; + +/** +* Returns an accessed value. +* +* @param value - array element +* @param aidx - array index +* @param sidx - strided index (offset + aidx*stride) +* @param array - input array +* @returns accessed value +*/ +type Quaternary = ( this: U, value: T, aidx: number, sidx: number, array: Collection ) => number | void; + +/** +* Returns an accessed value. +* +* @param value - array element +* @param aidx - array index +* @param sidx - strided index (offset + aidx*stride) +* @param array - input array +* @returns accessed value +*/ +type Callback = Nullary | Unary | Binary | Ternary | Quaternary; + +/** +* Interface describing `midrangeBy`. +*/ +interface Routine { + /** + * Computes the mid-range of a strided array via a callback function. + * + * ## Notes + * + * - The callback function is provided four arguments: + * + * - `value`: array element + * - `aidx`: array index + * - `sidx`: strided index (offset + aidx*stride) + * - `array`: input array + * + * - The callback function should return a numeric value. If the callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is ignored. + * + * @param N - number of indexed elements + * @param x - input array + * @param strideX - stride length + * @param clbk - callback + * @param thisArg - execution context + * @returns mid-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 = midrangeBy( x.length, x, 1, accessor ); + * // returns -1.0 + */ + ( N: number, x: InputArray, strideX: number, clbk: Callback, thisArg?: ThisParameterType> ): number; + + /** + * Computes the mid-range of a strided array via a callback function and using alternative indexing semantics. + * + * ## Notes + * + * - The callback function is provided four arguments: + * + * - `value`: array element + * - `aidx`: array index + * - `sidx`: strided index (offset + aidx*stride) + * - `array`: input array + * + * - The callback function should return a numeric value. If the callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is ignored. + * + * @param N - number of indexed elements + * @param x - input array + * @param strideX - stride length + * @param offsetX - starting index + * @param clbk - callback + * @param thisArg - execution context + * @returns mid-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 = midrangeBy.ndarray( x.length, x, 1, 0, accessor ); + * // returns -1.0 + */ + ndarray( N: number, x: InputArray, strideX: number, offsetX: number, clbk: Callback, thisArg?: ThisParameterType> ): number; +} + +/** +* Computes the mid-range of a strided array via a callback function. +* +* ## Notes +* +* - The callback function is provided four arguments: +* +* - `value`: array element +* - `aidx`: array index +* - `sidx`: strided index (offset + aidx*stride) +* - `array`: input array +* +* - The callback function should return a numeric value. If the callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is ignored. +* +* @param N - number of indexed elements +* @param x - input array +* @param strideX - stride length +* @param clbk - callback +* @param thisArg - execution context +* @returns mid-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 = midrangeBy( x.length, x, 1, accessor ); +* // returns -1.0 +* +* @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 = midrangeBy.ndarray( x.length, x, 1, 0, accessor ); +* // returns -1.0 +*/ +declare var midrangeBy: Routine; + + +// EXPORTS // + +export = midrangeBy; diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/types/test.ts b/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/types/test.ts new file mode 100644 index 000000000000..a9f710353450 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/types/test.ts @@ -0,0 +1,192 @@ +/* +* @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. +*/ + +import AccessorArray = require( '@stdlib/array/base/accessor' ); +import midrangeBy = require( './index' ); + +const accessor = (): number => { + return 5.0; +}; + + +// TESTS // + +// The function returns a number... +{ + const x = new Float64Array( 10 ); + + midrangeBy( x.length, x, 1, accessor ); // $ExpectType number + midrangeBy( x.length, new AccessorArray ( x ), 1, accessor ); // $ExpectType number + + midrangeBy( x.length, x, 1, accessor, {} ); // $ExpectType number + midrangeBy( 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... +{ + const x = new Float64Array( 10 ); + + midrangeBy( '10', x, 1, accessor ); // $ExpectError + midrangeBy( true, x, 1, accessor ); // $ExpectError + midrangeBy( false, x, 1, accessor ); // $ExpectError + midrangeBy( null, x, 1, accessor ); // $ExpectError + midrangeBy( undefined, x, 1, accessor ); // $ExpectError + midrangeBy( [], x, 1, accessor ); // $ExpectError + midrangeBy( {}, x, 1, accessor ); // $ExpectError + midrangeBy( ( x: number ): number => x, x, 1, accessor ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a collection... +{ + const x = new Float64Array( 10 ); + + midrangeBy( x.length, 10, 1, accessor ); // $ExpectError + midrangeBy( x.length, true, 1, accessor ); // $ExpectError + midrangeBy( x.length, false, 1, accessor ); // $ExpectError + midrangeBy( x.length, null, 1, accessor ); // $ExpectError + midrangeBy( x.length, undefined, 1, accessor ); // $ExpectError + midrangeBy( x.length, {}, 1, accessor ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float64Array( 10 ); + + midrangeBy( x.length, x, '10', accessor ); // $ExpectError + midrangeBy( x.length, x, true, accessor ); // $ExpectError + midrangeBy( x.length, x, false, accessor ); // $ExpectError + midrangeBy( x.length, x, null, accessor ); // $ExpectError + midrangeBy( x.length, x, undefined, accessor ); // $ExpectError + midrangeBy( x.length, x, [], accessor ); // $ExpectError + midrangeBy( x.length, x, {}, accessor ); // $ExpectError + midrangeBy( 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... +{ + const x = new Float64Array( 10 ); + + midrangeBy( x.length, x, 1, '10' ); // $ExpectError + midrangeBy( x.length, x, 1, true ); // $ExpectError + midrangeBy( x.length, x, 1, false ); // $ExpectError + midrangeBy( x.length, x, 1, null ); // $ExpectError + midrangeBy( x.length, x, 1, undefined ); // $ExpectError + midrangeBy( x.length, x, 1, [] ); // $ExpectError + midrangeBy( x.length, x, 1, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + + midrangeBy(); // $ExpectError + midrangeBy( x.length ); // $ExpectError + midrangeBy( x.length, x ); // $ExpectError + midrangeBy( x.length, x, 1 ); // $ExpectError + midrangeBy( x.length, x, 1, accessor, {}, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const x = new Float64Array( 10 ); + + midrangeBy.ndarray( x.length, x, 1, 0, accessor ); // $ExpectType number + midrangeBy.ndarray( x.length, new AccessorArray ( x ), 1, 0, accessor ); // $ExpectType number + + midrangeBy.ndarray( x.length, x, 1, 0, accessor, {} ); // $ExpectType number + midrangeBy.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... +{ + const x = new Float64Array( 10 ); + + midrangeBy.ndarray( '10', x, 1, 0, accessor ); // $ExpectError + midrangeBy.ndarray( true, x, 1, 0, accessor ); // $ExpectError + midrangeBy.ndarray( false, x, 1, 0, accessor ); // $ExpectError + midrangeBy.ndarray( null, x, 1, 0, accessor ); // $ExpectError + midrangeBy.ndarray( undefined, x, 1, 0, accessor ); // $ExpectError + midrangeBy.ndarray( [], x, 1, 0, accessor ); // $ExpectError + midrangeBy.ndarray( {}, x, 1, 0, accessor ); // $ExpectError + midrangeBy.ndarray( ( x: number ): number => x, x, 1, 0, accessor ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a collection... +{ + const x = new Float64Array( 10 ); + + midrangeBy.ndarray( x.length, 10, 1, 0, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, true, 1, 0, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, false, 1, 0, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, null, 1, 0, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, undefined, 1, 0, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, {}, 1, 0, accessor ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const x = new Float64Array( 10 ); + + midrangeBy.ndarray( x.length, x, '10', 0, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, true, 0, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, false, 0, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, null, 0, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, undefined, 0, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, [], 0, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, {}, 0, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, ( x: number ): number => x, 0, accessor ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + + midrangeBy.ndarray( x.length, x, 1, '10', accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, true, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, false, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, null, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, undefined, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, [], accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, {}, accessor ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, ( x: number ): number => x, accessor ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a function... +{ + const x = new Float64Array( 10 ); + + midrangeBy.ndarray( x.length, x, 1, 0, '10' ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, 0, true ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, 0, false ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, 0, null ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, 0, undefined ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, 0, [] ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, 0, {} ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + + midrangeBy.ndarray(); // $ExpectError + midrangeBy.ndarray( x.length ); // $ExpectError + midrangeBy.ndarray( x.length, x ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1 ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, 0 ); // $ExpectError + midrangeBy.ndarray( x.length, x, 1, 0, accessor, {}, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/examples/index.js b/lib/node_modules/@stdlib/stats/strided/midrange-by/examples/index.js new file mode 100644 index 000000000000..05c56152bf41 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/examples/index.js @@ -0,0 +1,34 @@ +/** +* @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'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var midrangeBy = require( './../lib' ); + +function accessor( v ) { + return v * 2.0; +} + +var x = discreteUniform( 10, -50, 50, { + 'dtype': 'float64' +}); +console.log( x ); + +var v = midrangeBy( x.length, x, 1, accessor ); +console.log( v ); diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/strided/midrange-by/lib/accessors.js new file mode 100644 index 000000000000..c732a63310a3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/lib/accessors.js @@ -0,0 +1,115 @@ +/** +* @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 isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Computes the mid-range of a strided array via a callback function. +* +* @param {PositiveInteger} N - number of indexed elements +* @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} mid-range +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var x = toAccessorArray( [ -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 = midrangeBy( x.length, arraylike2object( x ), 1, 0, accessor ); +* // returns -1.0 +*/ +function midrangeBy( N, x, strideX, offsetX, clbk, thisArg) { + var xbuf; + var get; + var max; + var min; + var ix; + 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, offsetX, xbuf ); + if ( v === void 0 || isnan( v ) ) { + return NaN; + } + return v; + } + ix = offsetX; + for ( i = 0; i < N; i++ ) { + min = clbk.call( thisArg, get( xbuf, ix ), i, ix, xbuf ); + if ( min !== void 0 ) { + break; + } + ix += strideX; + } + if ( i === N ) { + return NaN; + } + if ( isnan( min ) ) { + return min; + } + max = min; + i += 1; + for ( i; i < N; i++ ) { + ix += strideX; + v = clbk.call( thisArg, get( xbuf, ix ), i, ix, xbuf ); + if ( v === void 0 ) { + continue; + } + if ( isnan( v ) ) { + return v; + } + if ( v < min || ( v === min && isNegativeZero( v ) ) ) { + min = v; + } else if ( v > max || ( v === max && isPositiveZero( v ) ) ) { + max = v; + } + } + return ( max + min ) / 2.0; +} + + +// EXPORTS // + +module.exports = midrangeBy; diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/lib/index.js b/lib/node_modules/@stdlib/stats/strided/midrange-by/lib/index.js new file mode 100644 index 000000000000..93573ef3bae2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/lib/index.js @@ -0,0 +1,67 @@ +/** +* @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'; + +/** +* Compute the mid-range of a strided array via a callback function. +* +* @module @stdlib/stats/strided/midrange-by +* +* @example +* var midrangeBy = require( '@stdlib/stats/strided/midrange-by' ); +* +* 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 v = midrangeBy( x.length, x, 1, accessor ); +* // returns -1.0 +* +* @example +* var midrangeBy = require( '@stdlib/stats/strided/midrange-by' ); +* +* 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 v = midrangeBy.ndarray( x.length, x, 1, 0, accessor ); +* // returns -1.0 +*/ + +// 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 // + +module.exports = main; + +// exports: { "ndarray": "main.ndarray" } diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/lib/main.js b/lib/node_modules/@stdlib/stats/strided/midrange-by/lib/main.js new file mode 100644 index 000000000000..8efd2762f376 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/lib/main.js @@ -0,0 +1,56 @@ +/** +* @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 // + +/** +* Computes the mid-range of a strided array via a callback function. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Collection} x - input array +* @param {integer} strideX - index increment +* @param {Callback} clbk - callback +* @param {*} [thisArg] - execution context +* @returns {number} mid-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 = midrangeBy( x.length, x, 1, accessor ); +* // returns -1.0 +*/ +function midrangeBy( N, x, strideX, clbk, thisArg ) { + return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg ); +} + + +// EXPORTS // + +module.exports = midrangeBy; diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/lib/ndarray.js b/lib/node_modules/@stdlib/stats/strided/midrange-by/lib/ndarray.js new file mode 100644 index 000000000000..248d7c2a8662 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/lib/ndarray.js @@ -0,0 +1,112 @@ +/** +* @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 isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var accessors = require( './accessors.js' ); + + +// MAIN // + +/** +* Computes the mid-range of a strided array via a callback function. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Collection} x - input array +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index +* @param {Callback} clbk - callback +* @param {*} [thisArg] - execution context +* @returns {number} mid-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 = midrangeBy( x.length, x, 1, 0, accessor ); +* // returns -1.0 +*/ +function midrangeBy( N, x, strideX, offsetX, clbk, thisArg ) { + var max; + var min; + var ix; + var v; + var i; + var o; + + if ( N <= 0 ) { + return NaN; + } + o = arraylike2object( x ); + if ( o.accessorProtocol ) { + return accessors( N, o, strideX, offsetX, clbk, thisArg ); + } + if ( N === 1 || strideX === 0 ) { + v = clbk.call( thisArg, x[ offsetX ], 0, offsetX, x ); + if ( v === void 0 || isnan( v ) ) { + return NaN; + } + return v; + } + ix = offsetX; + for ( i = 0; i < N; i++ ) { + min = clbk.call( thisArg, x[ ix ], i, ix, x ); + if ( min !== void 0 ) { + break; + } + ix += strideX; + } + if ( i === N ) { + return NaN; + } + if ( isnan( min ) ) { + return min; + } + max = min; + i += 1; + for ( i; i < N; i++ ) { + ix += strideX; + v = clbk.call( thisArg, x[ ix ], i, ix, x ); + if ( v === void 0 ) { + continue; + } + if ( isnan( v ) ) { + return v; + } + if ( v < min || ( v === min && isNegativeZero( v ) ) ) { + min = v; + } else if ( v > max || ( v === max && isPositiveZero( v ) ) ) { + max = v; + } + } + return ( max + min ) / 2.0; +} + + +// EXPORTS // + +module.exports = midrangeBy; diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/package.json b/lib/node_modules/@stdlib/stats/strided/midrange-by/package.json new file mode 100644 index 000000000000..3c353f4a6d58 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/stats/strided/midrange-by", + "version": "0.0.0", + "description": "Calculate the mid-range of a strided array via a callback function.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "mathematics", + "math", + "midrange", + "minimum", + "min", + "maximum", + "max", + "extremes", + "strided", + "strided array", + "array" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/test/test.js b/lib/node_modules/@stdlib/stats/strided/midrange-by/test/test.js new file mode 100644 index 000000000000..53627e743002 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/test/test.js @@ -0,0 +1,38 @@ +/** +* @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 tape = require( 'tape' ); +var midrangeBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof midrangeBy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof midrangeBy.ndarray, 'function', 'method is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/test/test.main.js b/lib/node_modules/@stdlib/stats/strided/midrange-by/test/test.main.js new file mode 100644 index 000000000000..634bd5c55646 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/test/test.main.js @@ -0,0 +1,398 @@ +/** +* @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 tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var midrangeBy = require( './../lib' ); + + +// FUNCTIONS // + +function accessor( v ) { + if ( v === void 0 ) { + return; + } + return v * 2.0; +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof midrangeBy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( midrangeBy.length, 5, 'has expected arity' ); + t.end(); +}); + +tape( 'the function calculates the mid-range of a strided array via a callback function', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; + v = midrangeBy( x.length, x, 1, accessor ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + x = [ -4.0, -5.0 ]; + v = midrangeBy( x.length, x, 1, accessor ); + t.strictEqual( v, -9.0, 'returns expected value' ); + + x = [ -0.0, 0.0, -0.0 ]; + v = midrangeBy( x.length, x, 1, accessor ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + x = [ -0.0, -0.0 ]; + v = midrangeBy( x.length, x, 1, accessor ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + + x = [ NaN ]; + v = midrangeBy( x.length, x, 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ NaN, NaN ]; + v = midrangeBy( x.length, x, 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array + v = midrangeBy( x.length, x, 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array + x[ 2 ] = 1.0; + v = midrangeBy( x.length, x, 1, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the mid-range of a strided array via a callback function (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; + v = midrangeBy( x.length, toAccessorArray( x ), 1, accessor ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + x = [ -4.0, -5.0 ]; + v = midrangeBy( x.length, toAccessorArray( x ), 1, accessor ); + t.strictEqual( v, -9.0, 'returns expected value' ); + + x = [ -0.0, 0.0, -0.0 ]; + v = midrangeBy( x.length, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + x = [ NaN ]; + v = midrangeBy( x.length, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ NaN, NaN ]; + v = midrangeBy( x.length, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array + v = midrangeBy( x.length, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array + x[ 2 ] = 1.0; + v = midrangeBy( x.length, toAccessorArray( x ), 1, accessor ); + t.strictEqual( v, 2.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; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = midrangeBy( 0, x, 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = midrangeBy( -1, x, 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + 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 = midrangeBy( 0, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = midrangeBy( -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 the first element', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = midrangeBy( 1, x, 1, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + + v = midrangeBy( 1, 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 the first element (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = midrangeBy( 1, toAccessorArray( x ), 1, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + + v = midrangeBy( 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 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 = midrangeBy( 4, x, 2, accessor ); + + t.strictEqual( v, 2.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 = midrangeBy( 4, toAccessorArray( x ), 2, accessor ); + + t.strictEqual( v, 2.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `stride` parameter', 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 = midrangeBy( 4, x, -2, accessor ); + + t.strictEqual( v, 2.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 = midrangeBy( 4, toAccessorArray( x ), -2, accessor ); + + t.strictEqual( v, 2.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = midrangeBy( x.length, x, 0, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + + v = midrangeBy( 1, x, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = midrangeBy( x.length, toAccessorArray( x ), 0, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + + v = midrangeBy( 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 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 = midrangeBy( 4, x1, 2, accessor ); + t.strictEqual( v, 2.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 = midrangeBy( 4, toAccessorArray( x1 ), 2, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a callback execution context', function test( t ) { + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + midrangeBy( x.length, 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; + } +}); + +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 + }; + midrangeBy( 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; + } +}); diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/strided/midrange-by/test/test.ndarray.js new file mode 100644 index 000000000000..1b7e08a1ea2e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/test/test.ndarray.js @@ -0,0 +1,381 @@ +/** +* @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 tape = require( 'tape' ); +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 midrangeBy = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +function accessor( v ) { + if ( v === void 0 ) { + return; + } + return v * 2.0; +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof midrangeBy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( midrangeBy.length, 6, 'has expected arity' ); + t.end(); +}); + +tape( 'the function calculates the mid-range of a strided array via a callback function', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; + v = midrangeBy( x.length, x, 1, 0, accessor ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + x = [ -4.0, -5.0 ]; + v = midrangeBy( x.length, x, 1, 0, accessor ); + t.strictEqual( v, -9.0, 'returns expected value' ); + + x = [ -0.0, 0.0, -0.0 ]; + v = midrangeBy( x.length, x, 1, 0, accessor ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + x = [ NaN ]; + v = midrangeBy( x.length, x, 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ NaN, NaN ]; + v = midrangeBy( x.length, x, 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array + v = midrangeBy( x.length, x, 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array + x[ 2 ] = 1.0; + v = midrangeBy( x.length, x, 1, 0, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the mid-range of a strided array via a callback function (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; + v = midrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + x = [ -4.0, -5.0 ]; + v = midrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( v, -9.0, 'returns expected value' ); + + x = [ -0.0, 0.0, -0.0 ]; + v = midrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + x = [ NaN ]; + v = midrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ NaN, NaN ]; + v = midrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array + v = midrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array + x[ 2 ] = 1.0; + v = midrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( v, 2.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; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = midrangeBy( 0, x, 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = midrangeBy( -1, x, 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + 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 = midrangeBy( 0, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = midrangeBy( -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 the first element', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = midrangeBy( 1, x, 1, 0, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + + v = midrangeBy( 1, 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 the first element (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = midrangeBy( 1, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + + v = midrangeBy( 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 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 = midrangeBy( 4, x, 2, 0, accessor ); + + t.strictEqual( v, 2.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 = midrangeBy( 4, toAccessorArray( x ), 2, 0, accessor ); + + t.strictEqual( v, 2.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `stride` parameter', 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 = midrangeBy( 4, x, -2, 6, accessor ); + + t.strictEqual( v, 2.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 = midrangeBy( 4, toAccessorArray( x ), -2, 6, accessor ); + + t.strictEqual( v, 2.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = midrangeBy( x.length, x, 0, 0, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + + v = midrangeBy( 1, x, 0, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = midrangeBy( x.length, toAccessorArray( x ), 0, 0, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + + v = midrangeBy( 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; + + x = [ + 1.0, + -2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + -6.0 // 2 + ]; + + v = midrangeBy( 3, x, 2, 1, accessor ); + t.strictEqual( v, -2.0, 'returns expected value' ); + + 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 = midrangeBy( 3, toAccessorArray( x ), 2, 1, accessor ); + t.strictEqual( v, -2.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a callback execution context', function test( t ) { + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + midrangeBy( x.length, 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; + } +}); + +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 + }; + midrangeBy( 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; + } +}); From 93c9c660ef05cfa75f6cbd1de282bde3c4088fde Mon Sep 17 00:00:00 2001 From: orthodox-64 Date: Tue, 23 Dec 2025 21:50:03 +0530 Subject: [PATCH 2/3] fix: lint --- .../stats/strided/midrange-by/docs/repl.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/repl.txt b/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/repl.txt index 079a1bcfd7f1..ba44333ab6c9 100644 --- a/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/repl.txt @@ -59,15 +59,19 @@ 2.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 ); + > 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 ); > {{alias}}( 3, x1, 2, accessor ) -8.0 -{{alias}}.ndarray( N, x, strideX, offsetX, clbk[, thisArg] ) - Calculates the mid-range of a strided array via a callback function and using - alternative indexing semantics. +{{alias}}.ndarray( N, x, strideX, offsetX, clbk[, + thisArg] ) + Calculates the mid-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 From 9c6c9040e0bf456ef391cb73911887f65e1dbed7 Mon Sep 17 00:00:00 2001 From: orthodox-64 Date: Tue, 23 Dec 2025 23:06:09 +0530 Subject: [PATCH 3/3] fixed lint --- .../@stdlib/stats/strided/midrange-by/docs/repl.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/repl.txt b/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/repl.txt index ba44333ab6c9..66efac803ddd 100644 --- a/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/strided/midrange-by/docs/repl.txt @@ -68,8 +68,7 @@ -8.0 -{{alias}}.ndarray( N, x, strideX, offsetX, clbk[, - thisArg] ) +{{alias}}.ndarray( N, x, strideX, offsetX, clbk[, thisArg] ) Calculates the mid-range of a strided array via a callback function and using alternative indexing semantics.