From 458483fd38b7bf8aa8a967cf07f8800f9fb3aecf Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Thu, 7 Aug 2025 08:01:08 +0000 Subject: [PATCH 1/6] feat: add ndarray/base/nullary-strided1d-dispatch-factory --- .../README.md | 238 +++++++++ .../benchmark/benchmark.assign.js | 122 +++++ .../benchmark/benchmark.js | 62 +++ .../docs/repl.txt | 105 ++++ .../docs/types/index.d.ts | 242 +++++++++ .../docs/types/test.ts | 473 ++++++++++++++++++ .../examples/index.js | 76 +++ .../lib/index.js | 70 +++ .../lib/main.js | 123 +++++ .../package.json | 67 +++ .../test/test.js | 35 ++ 11 files changed, 1613 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/README.md b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/README.md new file mode 100644 index 000000000000..f4dc76548dfd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/README.md @@ -0,0 +1,238 @@ + + +# nullaryStrided1dDispatchFactory + +> Create a function for applying a strided function to an output ndarray. + +
+ +## Usage + + + +```javascript +var nullaryStrided1dDispatchFactory = require( '@stdlib/ndarray/base/nullary-strided1d-dispatch-factory' ); +``` + +#### nullaryStrided1dDispatchFactory( table, odtypes, policies\[, options] ) + +Returns a function for applying a strided function to an output ndarray. + + + +```javascript +var base = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); + +var table = { + 'default': base +}; + +var dtypes = [ 'float64', 'float32', 'generic' ]; +var policies = { + 'output': 'same' +}; + +var nullary = nullaryStrided1dDispatchFactory( table, [ dtypes ], policies ); +``` + +The function has the following parameters: + +- **table**: strided function dispatch table. Must have the following properties: + + - **default**: default strided function which should be invoked when provided ndarrays have data types which do not have a corresponding specialized implementation. + + A dispatch table may have the following additional properties: + + - **types**: one-dimensional list of ndarray data types describing specialized output ndarray argument signatures. Only the output ndarray argument data types should be specified. Additional ndarray argument data types should be omitted and are not considered during dispatch. The length of `types` must equal the number of strided functions specified by `fcns`. + - **fcns**: list of strided functions which are specific to specialized output ndarray argument signatures. + +- **odtypes**: list containing lists of supported output data types for each input ndarray argument. + +- **policies**: dispatch policies. Must have the following properties: + + - **output**: output data type [policy][@stdlib/ndarray/output-dtype-policies]. + +- **options**: function options (_optional_). + +The function supports the following options: + +- **strictTraversalOrder**: boolean specifying whether the order of element traversal must match the memory layout order of an input ndarray. Default: `false`. + +#### unary.assign( x\[, ...args]\[, options] ) + +Applies a strided function and assigns results to a provided output ndarray. + + + +```javascript +var base = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); +var dtypes = require( '@stdlib/ndarray/dtypes' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); + +var odt = dtypes( 'real_and_generic' ); +var policies = { + 'output': 'same' +}; + +var table = { + 'default': base +}; +var nullary = nullaryStrided1dDispatchFactory( table, [ odt ], policies ); + +var xbuf = [ -1.0, 2.0, -3.0 ]; +var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); + +var o = scalar2ndarray( 1.0, { + 'dtype': 'generic' +}); + +var out = nullary.assign( x, o ); +// returns + +var arr = ndarray2array( out ); +// returns [ -3.0, -1.0, 2.0 ] + +var bool = ( out === x ); +// returns true +``` + +The method has the following parameters: + +- **x**: output ndarray. +- **args**: additional output ndarray arguments (_optional_). +- **options**: function options (_optional_). + +The method accepts the following options: + +- **dims**: list of dimensions over which to perform operation. + +
+ + + +
+ +## Notes + +- A strided function should have the following signature: + + ```text + f( arrays ) + ``` + + where + + - **arrays**: array containing an output ndarray, followed by any additional ndarray arguments. + +- The output data type policy only applies to the function returned by the main function. For the `assign` method, the output ndarray is allowed to have any supported output data type. + +
+ + + +
+ +## Examples + + + + + +```javascript +var dsorthp = require( '@stdlib/blas/ext/base/ndarray/dsorthp' ); +var ssorthp = require( '@stdlib/blas/ext/base/ndarray/ssorthp' ); +var base = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var dtypes = require( '@stdlib/ndarray/dtypes' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var nullaryStrided1dDispatchFactory = require( '@stdlib/ndarray/base/nullary-strided1d-dispatch-factory' ); + +// Define the supported output data types: +var odt = dtypes( 'all' ); + +// Define dispatch policies: +var policies = { + 'output': 'same' +}; + +// Define a dispatch table: +var table = { + 'types': [ + 'float64', + 'float32' + ], + 'fcns': [ + dsorthp, + ssorthp + ], + 'default': base +}; + +// Create an interface for performing an operation: +var sorthp = nullaryStrided1dDispatchFactory( table, [ odt ], policies ); + +// Generate an array of random numbers: +var xbuf = discreteUniform( 25, -10, 10, { + 'dtype': 'generic' +}); + +// Wrap in an ndarray: +var x = new ndarray( 'generic', xbuf, [ 5, 5 ], [ 5, 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var o = scalar2ndarray( 1.0, { + 'dtype': 'generic' +}); + +// Perform operation: +sorthp.assign( x, o, { + 'dims': [ 0 ] +}); + +// Print the results: +console.log( ndarray2array( x ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js new file mode 100644 index 000000000000..a295be37513f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js @@ -0,0 +1,122 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var dtypes = require( '@stdlib/array/dtypes' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var gsorthp = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var policies; + var nullary; + var table; + var dt; + var x; + var o; + + table = { + 'default': gsorthp + }; + dt = dtypes( 'all' ); + policies = { + 'output': 'same' + }; + nullary = factory( table, [ dt ], policies ); + + x = uniform( len, -50.0, 50.0, { + 'dtype': 'float64' + }); + x = new ndarray( 'float64', x, [ len ], [ 1 ], 0, 'row-major' ); + o = scalar2ndarray( 1.0, { + 'dtype': 'generic' + }); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var o; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + o = nullary.assign( x, o ); + if ( typeof o !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( o.get( i%len ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +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( pkg+':assign:len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.js new file mode 100644 index 000000000000..84a6df88a61e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.js @@ -0,0 +1,62 @@ +/** +* @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 gsorthp = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( pkg+'::factory', function benchmark( b ) { + var policies; + var dtypes; + var table; + var v; + var i; + + table = { + 'default': gsorthp + }; + dtypes = [ + 'float64', + 'float32' + ]; + policies = { + 'output': 'same' + }; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = factory( table, [ dtypes ], policies ); + if ( typeof v !== 'function' ) { + b.fail( 'should return a function' ); + } + } + b.toc(); + if ( typeof v !== 'function' ) { + b.fail( 'should return a function' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/repl.txt new file mode 100644 index 000000000000..46a8428c02e3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/repl.txt @@ -0,0 +1,105 @@ + +{{alias}}( table, odtypes, policies[, options] ) + Returns function for applying a strided function to an output ndarray. + + Parameters + ---------- + table: Object + Dispatch table containing strided functions. The table object must have + the following property: + + - default: default strided function to invoke when provided ndarrays + have data types which do not have a corresponding specialized + implementation. + + The table may having the following additional properties: + + - types: one-dimensional list of ndarray data types describing + specialized output ndarray argument signatures. + - fcns: list of strided functions which are specific to specialized + output ndarray argument signatures. + + A strided function should have the following signature: + + f( arrays ) + + where + + - arrays: array containing an output ndarray, followed by any additional + ndarray arguments. + + odtypes: Array> + List containing lists of supported output array data types for each + output ndarray argument. + + policies: Object + Dispatch policies. Must have the following properties: + + - output: output data type policy. + + options: Object (optional) + Function options. + + options.strictTraversalOrder: boolean (optional) + Boolean specifying whether the order of element traversal must match the + memory layout order of an output ndarray. + + Returns + ------- + fcn: Function + Function for applying a strided function to ndarrays. + + Examples + -------- + > var dt = [ 'float64', 'float32', 'generic' ]; + > var p = { 'output': 'same' }; + > var t = { 'default': {{alias:@stdlib/blas/ext/base/ndarray/gsorthp}} }; + > var f = {{alias}}( t, [ dt ], p ); + +fcn.assign( x[, ...args][, options] ) + Applies a strided function and assign results to a provided output ndarray. + + Parameters + ---------- + x: ndarray + Input array. + + args: ...ndarray (optional) + Additional ndarray arguments. + + options: Object (optional) + Function options. + + options.dims: Array (optional) + List of dimensions over which to perform operation. If not provided, the + function performs the operation over all elements in a provided output + ndarray. + + Returns + ------- + out: ndarray + Output array. + + Examples + -------- + > var dts = [ 'float64', 'float32', 'generic' ]; + > var p = { 'output': 'same' }; + > var t = { 'default': {{alias:@stdlib/blas/ext/base/ndarray/gsorthp}} }; + > var f = {{alias}}( t, [ dts ], p ); + > var buf = [ -1.0, 2.0, -3.0, -4.0 ]; + > var dt = 'generic'; + > var sh = [ buf.length ]; + > var sx = [ 1 ]; + > var ox = 0; + > var ord = 'row-major'; + > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, buf, sh, sx, ox, ord ); + > var o = {{alias:@stdlib/ndarray/from-scalar}}( 1.0 ); + > var out = f.assign( x, o ) + + > var bool = ( out === x ) + true + > {{alias:@stdlib/ndarray/to-array}}( x ) + [ -4.0, -3.0, -1.0, 2.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/index.d.ts new file mode 100644 index 000000000000..6d1c72e61690 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/index.d.ts @@ -0,0 +1,242 @@ +/* +* @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 { ArrayLike } from '@stdlib/types/array'; +import { OutputPolicy, DataType, typedndarray } from '@stdlib/types/ndarray'; + +/** +* Input array. +*/ +type InputArray = typedndarray; + +/** +* Output array. +*/ +type OutputArray = typedndarray; + +/** +* Interface defining "base" options. +*/ +interface BaseOptions { + /** + * List of dimensions over which to perform an operation. + */ + dims?: ArrayLike; +} + +/** +* Interface defining factory options. +*/ +interface FactoryOptions { + /** + * Boolean specifying whether the order of element traversal must match the memory layout of an input ndarray. + */ + strictTraversalOrder?: boolean; +} + +/** +* Strided function. +* +* @param arrays - output ndarrays +* @param options - function options +* @returns result +*/ +type Nullary = ( arrays: [ typedndarray ], options?: unknown ) => typedndarray; + +/** +* Strided function. +* +* @param arrays - output ndarrays +* @param options - function options +* @returns result +*/ +type NullaryWithAdditionalArrays = ( arrays: [ typedndarray, ...Array> ], options?: unknown ) => typedndarray; + +/** +* Base dispatch table. +*/ +interface BaseDispatchTable { + /** + * Default strided function. + */ + default: Nullary | NullaryWithAdditionalArrays; +} + +/** +* Dispatch table. +*/ +interface DispatchTable extends BaseDispatchTable { + /** + * One-dimensional list of ndarray data types describing specialized output ndarray argument signatures. + */ + types: ArrayLike; + + /** + * List of strided functions which are specific to specialized output ndarray argument signatures. + */ + fcns: ArrayLike | NullaryWithAdditionalArrays>; +} + +/** +* Dispatch policies. +*/ +interface Policies { + /** + * Output data type policy. + */ + output: OutputPolicy; +} + +/** +* Interface for applying an operation to an ndarray. +*/ +interface NullaryFunction { + /** + * Applies a strided function and assign results to a provided output ndarray. + * + * @param x - output ndarray + * @param options - function options + * @returns output ndarray + * + * @example + * var base = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); + * var dtypes = require( '@stdlib/ndarray/dtypes' ); + * var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var ndarray = require( '@stdlib/ndarray/base/ctor' ); + * + * var odt = dtypes( 'all' ); + * var policies = { + * 'output': 'same' + * }; + * + * var table = { + * 'default': base + * }; + * var sorthp = factory( table, [ odt ], policy ); + * + * var xbuf = [ -1.0, 2.0, -3.0 ]; + * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); + * + * var out = sorthp.assign( x ); + * // returns + * + * var arr = ndarray2array( out ); + * // returns [ -3.0, -1.0, 2.0 ] + * + * var bool = ( out === x ); + * // returns true + */ + assign = OutputArray>( x: V, options?: BaseOptions ): V; + + /** + * Applies a strided function and assigns results to a provided output ndarray. + * + * @param x - input ndarray + * @param o - additional ndarray argument + * @param args - output ndarray, additional array arguments, and function options + * @returns output ndarray + * + * @example + * var base = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); + * var dtypes = require( '@stdlib/ndarray/dtypes' ); + * var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var ndarray = require( '@stdlib/ndarray/base/ctor' ); + * + * var odt = dtypes( 'all' ); + * var policies = { + * 'output': 'same' + * }; + * + * var table = { + * 'default': base + * }; + * var sorthp = factory( table, [ odt ], policy ); + * + * var xbuf = [ -1.0, 2.0, -3.0 ]; + * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); + * + * var o = scalar2ndarray( 1.0, { + * 'dtype': 'generic' + * }); + * + * var out = sorthp.assign( x, o ); + * // returns + * + * var arr = ndarray2array( out ); + * // returns [ -3.0, -1.0, 2.0 ] + * + * var bool = ( out === x ); + * // returns true + */ + assign = OutputArray>( x: T, ...args: Array ): V; +} + +/** +* Creates a function for applying a strided function to an output ndarray. +* +* @param table - dispatch table +* @param odtypes - list containing lists of supported output data types for each ndarray argument +* @param policies - dispatch policies +* @param options - function options +* @returns function for applying a unary function +* +* @example +* var base = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); +* var dtypes = require( '@stdlib/ndarray/dtypes' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* +* var odt = dtypes( 'all' ); +* var policies = { +* 'output': 'same' +* }; +* +* var table = { +* 'default': base +* }; +* var sorthp = factory( table, [ odt ], policy ); +* +* var xbuf = [ -1.0, 2.0, -3.0 ]; +* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +* +* var o = scalar2ndarray( 1.0, { +* 'dtype': 'generic' +* }); +* +* var out = sorthp.assign( x, o ); +* // returns +* +* var arr = ndarray2array( out ); +* // returns [ -3.0, -1.0, 2.0 ] +* +* var bool = ( out === x ); +* // returns true +*/ +declare function factory( table: DispatchTable | BaseDispatchTable, odtypes: ArrayLike>, policies: Policies, options?: FactoryOptions ): NullaryFunction; + + +// EXPORTS // + +export = factory; diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/test.ts new file mode 100644 index 000000000000..a4f457115326 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/test.ts @@ -0,0 +1,473 @@ +/* +* @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. +*/ + +/* eslint-disable @typescript-eslint/no-unused-expressions, space-in-parens */ + +/// + +import { DataType, OutputPolicy, InputCastingPolicy } from '@stdlib/types/ndarray'; +import cumax = require( '@stdlib/stats/base/ndarray/cumax' ); +import zeros = require( '@stdlib/ndarray/zeros' ); +import factory = require( './index' ); + + +// TESTS // + +// The function returns a function... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + + factory( table, [ dtypes ], dtypes, policies ); // $ExpectType UnaryFunction + factory( table, [ dtypes ], dtypes, policies, {} ); // $ExpectType UnaryFunction +} + +// The compiler throws an error if the function is provided a first argument which is not a dispatch table... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + + factory( '5', [ dtypes ], dtypes, policies ); // $ExpectError + factory( 5, [ dtypes ], dtypes, policies ); // $ExpectError + factory( true, [ dtypes ], dtypes, policies ); // $ExpectError + factory( false, [ dtypes ], dtypes, policies ); // $ExpectError + factory( null, [ dtypes ], dtypes, policies ); // $ExpectError + factory( void 0, [ dtypes ], dtypes, policies ); // $ExpectError + factory( 'abc', [ dtypes ], dtypes, policies ); // $ExpectError + factory( {}, [ dtypes ], dtypes, policies ); // $ExpectError + factory( ( x: number, y: number ): number => x + y, [ dtypes ], dtypes, policies ); // $ExpectError + + factory( '5', [ dtypes ], dtypes, policies, {} ); // $ExpectError + factory( 5, [ dtypes ], dtypes, policies, {} ); // $ExpectError + factory( true, [ dtypes ], dtypes, policies, {} ); // $ExpectError + factory( false, [ dtypes ], dtypes, policies, {} ); // $ExpectError + factory( null, [ dtypes ], dtypes, policies, {} ); // $ExpectError + factory( void 0, [ dtypes ], dtypes, policies, {} ); // $ExpectError + factory( 'abc', [ dtypes ], dtypes, policies, {} ); // $ExpectError + factory( {}, [ dtypes ], dtypes, policies, {} ); // $ExpectError + factory( ( x: number, y: number ): number => x + y, [ dtypes ], dtypes, policies, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a list of data type lists... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + + factory( table, '5', dtypes, policies ); // $ExpectError + factory( table, 5, dtypes, policies ); // $ExpectError + factory( table, true, dtypes, policies ); // $ExpectError + factory( table, false, dtypes, policies ); // $ExpectError + factory( table, null, dtypes, policies ); // $ExpectError + factory( table, void 0, dtypes, policies ); // $ExpectError + factory( table, 'abc', dtypes, policies ); // $ExpectError + factory( table, {}, dtypes, policies ); // $ExpectError + factory( table, ( x: number ): number => x, dtypes, policies ); // $ExpectError + + factory( table, '5', dtypes, policies, {} ); // $ExpectError + factory( table, 5, dtypes, policies, {} ); // $ExpectError + factory( table, true, dtypes, policies, {} ); // $ExpectError + factory( table, false, dtypes, policies, {} ); // $ExpectError + factory( table, null, dtypes, policies, {} ); // $ExpectError + factory( table, void 0, dtypes, policies, {} ); // $ExpectError + factory( table, 'abc', dtypes, policies, {} ); // $ExpectError + factory( table, {}, dtypes, policies, {} ); // $ExpectError + factory( table, ( x: number ): number => x, dtypes, policies, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a list of data types... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + + factory( table, [ dtypes ], '5', policies ); // $ExpectError + factory( table, [ dtypes ], 5, policies ); // $ExpectError + factory( table, [ dtypes ], true, policies ); // $ExpectError + factory( table, [ dtypes ], false, policies ); // $ExpectError + factory( table, [ dtypes ], null, policies ); // $ExpectError + factory( table, [ dtypes ], void 0, policies ); // $ExpectError + factory( table, [ dtypes ], 'abc', policies ); // $ExpectError + factory( table, [ dtypes ], {}, policies ); // $ExpectError + factory( table, [ dtypes ], ( x: number ): number => x, policies ); // $ExpectError + + factory( table, [ dtypes ], '5', policies, {} ); // $ExpectError + factory( table, [ dtypes ], 5, policies, {} ); // $ExpectError + factory( table, [ dtypes ], true, policies, {} ); // $ExpectError + factory( table, [ dtypes ], false, policies, {} ); // $ExpectError + factory( table, [ dtypes ], null, policies, {} ); // $ExpectError + factory( table, [ dtypes ], void 0, policies, {} ); // $ExpectError + factory( table, [ dtypes ], 'abc', policies, {} ); // $ExpectError + factory( table, [ dtypes ], {}, policies, {} ); // $ExpectError + factory( table, [ dtypes ], ( x: number ): number => x, policies, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a valid policy object... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + + factory( table, [ dtypes ], dtypes, '5' ); // $ExpectError + factory( table, [ dtypes ], dtypes, 5 ); // $ExpectError + factory( table, [ dtypes ], dtypes, true ); // $ExpectError + factory( table, [ dtypes ], dtypes, false ); // $ExpectError + factory( table, [ dtypes ], dtypes, null ); // $ExpectError + factory( table, [ dtypes ], dtypes, void 0 ); // $ExpectError + factory( table, [ dtypes ], dtypes, 'abc' ); // $ExpectError + factory( table, [ dtypes ], dtypes, {} ); // $ExpectError + factory( table, [ dtypes ], dtypes, ( x: number ): number => x ); // $ExpectError + + factory( table, [ dtypes ], dtypes, '5', {} ); // $ExpectError + factory( table, [ dtypes ], dtypes, 5, {} ); // $ExpectError + factory( table, [ dtypes ], dtypes, true, {} ); // $ExpectError + factory( table, [ dtypes ], dtypes, false, {} ); // $ExpectError + factory( table, [ dtypes ], dtypes, null, {} ); // $ExpectError + factory( table, [ dtypes ], dtypes, void 0, {} ); // $ExpectError + factory( table, [ dtypes ], dtypes, 'abc', {} ); // $ExpectError + factory( table, [ dtypes ], dtypes, {}, {} ); // $ExpectError + factory( table, [ dtypes ], dtypes, ( x: number ): number => x, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not an object... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + + factory( table, [ dtypes ], dtypes, policies, '5' ); // $ExpectError + factory( table, [ dtypes ], dtypes, policies, 5 ); // $ExpectError + factory( table, [ dtypes ], dtypes, policies, true ); // $ExpectError + factory( table, [ dtypes ], dtypes, policies, false ); // $ExpectError + factory( table, [ dtypes ], dtypes, policies, null ); // $ExpectError + factory( table, [ dtypes ], dtypes, policies, 'abc' ); // $ExpectError + factory( table, [ dtypes ], dtypes, policies, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + + factory(); // $ExpectError + factory( abs ); // $ExpectError + factory( table, [ dtypes ] ); // $ExpectError + factory( table, [ dtypes ], dtypes, policies, {}, {} ); // $ExpectError +} + +// The function returns a function which returns an ndarray... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + const f = factory( table, [ dtypes ], dtypes, policies ); + f( x ); // $ExpectType OutputArray + f( x, {} ); // $ExpectType OutputArray +} + +// The compiler throws an error if the returned function is provided a first argument which is not an ndarray... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + + const f = factory( table, [ dtypes ], dtypes, policies ); + f( '5' ); // $ExpectError + f( 5 ); // $ExpectError + f( true ); // $ExpectError + f( false ); // $ExpectError + f( null ); // $ExpectError + f( void 0 ); // $ExpectError + f( {} ); // $ExpectError + f( ( x: number ): number => x ); // $ExpectError + + f( '5', {} ); // $ExpectError + f( 5, {} ); // $ExpectError + f( true, {} ); // $ExpectError + f( false, {} ); // $ExpectError + f( null, {} ); // $ExpectError + f( void 0, {} ); // $ExpectError + f( {}, {} ); // $ExpectError + f( ( x: number ): number => x, {} ); // $ExpectError +} + +// The compiler throws an error if the returned function is provided an invalid second argument... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + const f = factory( table, [ dtypes ], dtypes, policies ); + f( x, '5' ); // $ExpectError + f( x, true ); // $ExpectError + f( x, false ); // $ExpectError + f( x, null ); // $ExpectError + f( x, [] ); // $ExpectError + f( x, ( x: number ): number => x ); // $ExpectError + + f( x, '5', {} ); // $ExpectError + f( x, true, {} ); // $ExpectError + f( x, false, {} ); // $ExpectError + f( x, null, {} ); // $ExpectError + f( x, [], {} ); // $ExpectError + f( x, ( x: number ): number => x, {} ); // $ExpectError +} + +// The compiler throws an error if the returned function is provided an invalid `dtype` option... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + const f = factory( table, [ dtypes ], dtypes, policies ); + f( x, { 'dtype': '5' } ); // $ExpectError + f( x, { 'dtype': 5 } ); // $ExpectError + f( x, { 'dtype': true } ); // $ExpectError + f( x, { 'dtype': false } ); // $ExpectError + f( x, { 'dtype': null } ); // $ExpectError + f( x, { 'dtype': [] } ); // $ExpectError + f( x, { 'dtype': {} } ); // $ExpectError + f( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the returned function is provided an invalid `dims` option... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + const f = factory( table, [ dtypes ], dtypes, policies ); + f( x, { 'dims': '5' } ); // $ExpectError + f( x, { 'dims': 5 } ); // $ExpectError + f( x, { 'dims': true } ); // $ExpectError + f( x, { 'dims': false } ); // $ExpectError + f( x, { 'dims': null } ); // $ExpectError + f( x, { 'dims': {} } ); // $ExpectError + f( x, { 'dims': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the returned function is provided an unsupported number of arguments... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + + const f = factory( table, [ dtypes ], dtypes, policies ); + f(); // $ExpectError +} + +// The function returns a function having an `assign` method which returns an ndarray... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + const f = factory( table, [ dtypes ], dtypes, policies ); + f.assign( x, x ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + const f = factory( table, [ dtypes ], dtypes, policies ); + f.assign( '5', x ); // $ExpectError + f.assign( 5, x ); // $ExpectError + f.assign( true, x ); // $ExpectError + f.assign( false, x ); // $ExpectError + f.assign( null, x ); // $ExpectError + f.assign( void 0, x ); // $ExpectError + f.assign( {}, x ); // $ExpectError + f.assign( ( x: number ): number => x, x ); // $ExpectError + + f.assign( '5', x, {} ); // $ExpectError + f.assign( 5, x, {} ); // $ExpectError + f.assign( true, x, {} ); // $ExpectError + f.assign( false, x, {} ); // $ExpectError + f.assign( null, x, {} ); // $ExpectError + f.assign( void 0, x, {} ); // $ExpectError + f.assign( {}, x, {} ); // $ExpectError + f.assign( ( x: number ): number => x, x, {} ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a second argument which is not an ndarray... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + const f = factory( table, [ dtypes ], dtypes, policies ); + f.assign( x, '5' ); // $ExpectError + f.assign( x, 5 ); // $ExpectError + f.assign( x, true ); // $ExpectError + f.assign( x, false ); // $ExpectError + f.assign( x, null ); // $ExpectError + f.assign( x, void 0 ); // $ExpectError + f.assign( x, ( x: number ): number => x ); // $ExpectError + + f.assign( x, '5', {} ); // $ExpectError + f.assign( x, 5, {} ); // $ExpectError + f.assign( x, true, {} ); // $ExpectError + f.assign( x, false, {} ); // $ExpectError + f.assign( x, null, {} ); // $ExpectError + f.assign( x, void 0, {} ); // $ExpectError + f.assign( x, ( x: number ): number => x, {} ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an invalid `dims` option... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + const f = factory( table, [ dtypes ], dtypes, policies ); + f.assign( x, x, { 'dims': '5' } ); // $ExpectError + f.assign( x, x, { 'dims': 5 } ); // $ExpectError + f.assign( x, x, { 'dims': true } ); // $ExpectError + f.assign( x, x, { 'dims': false } ); // $ExpectError + f.assign( x, x, { 'dims': null } ); // $ExpectError + f.assign( x, x, { 'dims': {} } ); // $ExpectError + f.assign( x, x, { 'dims': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... +{ + const dtypes: Array = [ 'float64', 'float32' ]; + const table = { + 'default': cumax + }; + const policies = { + 'output': 'same' as OutputPolicy, + 'casting': 'none' as InputCastingPolicy + }; + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + const f = factory( table, [ dtypes ], dtypes, policies ); + f.assign(); // $ExpectError + f.assign( x ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js new file mode 100644 index 000000000000..2ad078a4e649 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js @@ -0,0 +1,76 @@ +/** +* @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. +*/ + +/* eslint-disable array-element-newline */ + +'use strict'; + +var dsorthp = require( '@stdlib/blas/ext/base/ndarray/dsorthp' ); +var ssorthp = require( '@stdlib/blas/ext/base/ndarray/ssorthp' ); +var base = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var dtypes = require( '@stdlib/ndarray/dtypes' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var factory = require( './../lib' ); + +// Define the supported output data types: +var odt = dtypes( 'all' ); + +// Define dispatch policies: +var policies = { + 'output': 'same' +}; + +// Define a dispatch table: +var table = { + 'types': [ + 'float64', + 'float32' + ], + 'fcns': [ + dsorthp, + ssorthp + ], + 'default': base +}; + +// Create an interface for performing an operation: +var sorthp = factory( table, [ odt ], policies ); + +// Generate an array of random numbers: +var xbuf = discreteUniform( 25, -10, 10, { + 'dtype': 'generic' +}); + +// Wrap in an ndarray: +var x = new ndarray( 'generic', xbuf, [ 5, 5 ], [ 5, 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var o = scalar2ndarray( 1.0, { + 'dtype': 'generic' +}); + +// Perform operation: +sorthp.assign( x, o, { + 'dims': [ 0 ] +}); + +// Print the results: +console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/index.js new file mode 100644 index 000000000000..8f8e69ff6b0b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/index.js @@ -0,0 +1,70 @@ +/** +* @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'; + +/** +* Create a function for applying a strided function to an output ndarray. +* +* @module @stdlib/ndarray/base/nullary-strided1d-dispatch-factory +* +* @example +* var base = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); +* var dtypes = require( '@stdlib/ndarray/dtypes' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var factory = require( '@stdlib/ndarray/base/nullary-strided1d-dispatch-factory' ); +* +* var odt = dtypes( 'all' ); +* var policies = { +* 'output': 'same' +* }; +* +* var table = { +* 'default': base +* }; +* var sorthp = factory( table, [ odt ], policies ); +* +* var xbuf = [ -1.0, 2.0, -3.0 ]; +* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +* +* var o = scalar2ndarray( 1.0, { +* 'dtype': 'generic' +* }); +* +* var out = sorthp.assign( x, o ); +* // returns +* +* var arr = ndarray2array( x ); +* // returns [ -3.0, -1.0, 2.0 ] +* +* var bool = ( out === x ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; + +// exports: { "assign": "main.assign" } diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js new file mode 100644 index 000000000000..1c175f17e28e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js @@ -0,0 +1,123 @@ +/** +* @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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var NullaryStrided1dDispatch = require( '@stdlib/ndarray/base/nullary-strided1d-dispatch' ); + + +// MAIN // + +/** +* Returns a function for applying a strided function to an output ndarray. +* +* @param {Object} table - dispatch table +* @param {Function} table.default - default strided function +* @param {StringArray} [table.types] - one-dimensional list of ndarray data types describing specialized output ndarray argument signatures +* @param {ArrayLikeObject} [table.fcns] - list of strided functions which are specific to specialized output ndarray argument signatures +* @param {ArrayLikeObject} odtypes - list containing lists of supported output data types for each ndarray argument +* @param {Object} policies - policies +* @param {string} policies.output - output data type policy +* @param {Options} [options] - function options +* @param {boolean} [options.strictTraversalOrder=false] - boolean specifying whether to require that element traversal match the memory layout of an output ndarray +* @throws {TypeError} first argument must be an object having valid properties +* @throws {Error} first argument must be an object having valid properties +* @throws {TypeError} second argument must be an array containing arrays of supported data types +* @throws {TypeError} third argument must be an object having supported policies +* @throws {TypeError} options argument must be an object +* @throws {TypeError} must provide valid options +* @returns {Function} function for applying a strided function an ndarray +* +* @example +* var base = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); +* var dtypes = require( '@stdlib/ndarray/dtypes' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* +* var odt = dtypes( 'all' ); +* var policies = { +* 'output': 'same' +* }; +* +* var table = { +* 'default': base +* }; +* var sorthp = factory( table, [ odt ], policies ); +* +* var xbuf = [ -1.0, 2.0, -3.0 ]; +* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +* +* var o = scalar2ndarray( 1.0, { +* 'dtype': 'generic' +* }); +* +* var out = sorthp( x, o ); +* // returns +* +* var arr = ndarray2array( x ); +* // returns [ -3.0, -1.0, 2.0 ] +* +* var bool = ( out === x ); +* // returns true +*/ +function factory( table, odtypes, policies, options ) { + var f; + if ( arguments.length > 3 ) { + f = new NullaryStrided1dDispatch( table, odtypes, policies, options ); // eslint-disable-line max-len + } else { + f = new NullaryStrided1dDispatch( table, odtypes, policies ); + } + setReadOnly( assign, 'assign', assign ); + return assign; + + /** + * Applies a strided function and assigns results to a provided output ndarray. + * + * @private + * @param {ndarrayLike} x - output ndarray + * @param {...ndarrayLike} [args] - additional ndarray arguments + * @param {Options} [options] - function options + * @param {IntegerArray} [options.dims] - list of dimensions over which to perform operation + * @throws {TypeError} first argument must be an ndarray + * @throws {TypeError} first argument must have a supported data type + * @throws {TypeError} options argument must be an object + * @throws {RangeError} dimension indices must not exceed input ndarray bounds + * @throws {RangeError} number of dimension indices must not exceed the number of output ndarray dimensions + * @throws {Error} must provide valid options + * @returns {ndarrayLike} output ndarray + */ + function assign() { + var args; + var i; + + args = []; + for ( i = 0; i < arguments.length; i++ ) { + args.push( arguments[ i ] ); + } + return f.assign.apply( f, args ); + } +} + + +// EXPORTS // + +module.exports = factory; diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/package.json b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/package.json new file mode 100644 index 000000000000..755d48fc1e7c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/ndarray/base/nullary-strided1d-dispatch-factory", + "version": "0.0.0", + "description": "Create a function for applying a strided function to an output ndarray.", + "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", + "factory", + "function", + "func", + "fcn", + "ndarray", + "strided", + "vector", + "array", + "apply", + "cumulative", + "aggregation", + "aggregate", + "accumulate" + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/test/test.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/test/test.js new file mode 100644 index 000000000000..6a51e9ffda63 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/test/test.js @@ -0,0 +1,35 @@ +/** +* @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 factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +// FIXME: add tests From 4e90719ab5806e3898ff9022ba059773e47b10f0 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 17 Sep 2025 00:05:29 +0500 Subject: [PATCH 2/6] refactor: apply suggestions from code review --- .../README.md | 37 +- .../benchmark/benchmark.assign.js | 12 +- .../benchmark/benchmark.js | 15 +- .../docs/repl.txt | 26 +- .../docs/types/index.d.ts | 43 +- .../docs/types/test.ts | 435 ++++-------------- .../examples/index.js | 14 +- .../lib/index.js | 6 +- .../lib/main.js | 21 +- 9 files changed, 164 insertions(+), 445 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/README.md b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/README.md index f4dc76548dfd..25c114f173e3 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/README.md @@ -32,7 +32,7 @@ limitations under the License. var nullaryStrided1dDispatchFactory = require( '@stdlib/ndarray/base/nullary-strided1d-dispatch-factory' ); ``` -#### nullaryStrided1dDispatchFactory( table, odtypes, policies\[, options] ) +#### nullaryStrided1dDispatchFactory( table, idtypes, odtypes\[, options] ) Returns a function for applying a strided function to an output ndarray. @@ -46,11 +46,8 @@ var table = { }; var dtypes = [ 'float64', 'float32', 'generic' ]; -var policies = { - 'output': 'same' -}; -var nullary = nullaryStrided1dDispatchFactory( table, [ dtypes ], policies ); +var nullary = nullaryStrided1dDispatchFactory( table, [ dtypes ], dtypes ); ``` The function has the following parameters: @@ -64,11 +61,9 @@ The function has the following parameters: - **types**: one-dimensional list of ndarray data types describing specialized output ndarray argument signatures. Only the output ndarray argument data types should be specified. Additional ndarray argument data types should be omitted and are not considered during dispatch. The length of `types` must equal the number of strided functions specified by `fcns`. - **fcns**: list of strided functions which are specific to specialized output ndarray argument signatures. -- **odtypes**: list containing lists of supported output data types for each input ndarray argument. - -- **policies**: dispatch policies. Must have the following properties: +- **idtypes**: list containing lists of supported input data types for each input ndarray argument. - - **output**: output data type [policy][@stdlib/ndarray/output-dtype-policies]. +- **odtypes**: list of supported output data types. - **options**: function options (_optional_). @@ -89,15 +84,13 @@ var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var ndarray2array = require( '@stdlib/ndarray/to-array' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); -var odt = dtypes( 'real_and_generic' ); -var policies = { - 'output': 'same' -}; +var idt = dtypes( 'real_and_generic' ); +var odt = dtypes( 'all' ); var table = { 'default': base }; -var nullary = nullaryStrided1dDispatchFactory( table, [ odt ], policies ); +var nullary = nullaryStrided1dDispatchFactory( table, [ idt ], odt ); var xbuf = [ -1.0, 2.0, -3.0 ]; var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); @@ -169,14 +162,10 @@ var ndarray2array = require( '@stdlib/ndarray/to-array' ); var ndarray = require( '@stdlib/ndarray/ctor' ); var nullaryStrided1dDispatchFactory = require( '@stdlib/ndarray/base/nullary-strided1d-dispatch-factory' ); -// Define the supported output data types: +// Define the supported input and output data types: +var idt = dtypes( 'real_and_generic' ); var odt = dtypes( 'all' ); -// Define dispatch policies: -var policies = { - 'output': 'same' -}; - // Define a dispatch table: var table = { 'types': [ @@ -191,7 +180,7 @@ var table = { }; // Create an interface for performing an operation: -var sorthp = nullaryStrided1dDispatchFactory( table, [ odt ], policies ); +var sorthp = nullaryStrided1dDispatchFactory( table, [ idt ], odt ); // Generate an array of random numbers: var xbuf = discreteUniform( 25, -10, 10, { @@ -207,9 +196,7 @@ var o = scalar2ndarray( 1.0, { }); // Perform operation: -sorthp.assign( x, o, { - 'dims': [ 0 ] -}); +sorthp.assign( x, o ); // Print the results: console.log( ndarray2array( x ) ); @@ -231,8 +218,6 @@ console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js index a295be37513f..a0599a38e9e8 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js @@ -42,21 +42,19 @@ var factory = require( './../lib' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var policies; var nullary; var table; - var dt; + var idt; + var odt; var x; var o; table = { 'default': gsorthp }; - dt = dtypes( 'all' ); - policies = { - 'output': 'same' - }; - nullary = factory( table, [ dt ], policies ); + idt = dtypes( 'real_and_generic' ); + odt = dtypes( 'all' ); + nullary = factory( table, [ idt ], odt ); x = uniform( len, -50.0, 50.0, { 'dtype': 'float64' diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.js index 84a6df88a61e..d71dd3c3095d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.js @@ -29,8 +29,8 @@ var factory = require( './../lib' ); // MAIN // bench( pkg+'::factory', function benchmark( b ) { - var policies; - var dtypes; + var idtypes; + var odtypes; var table; var v; var i; @@ -38,17 +38,18 @@ bench( pkg+'::factory', function benchmark( b ) { table = { 'default': gsorthp }; - dtypes = [ + idtypes = [ + 'float64', + 'float32' + ]; + odtypes = [ 'float64', 'float32' ]; - policies = { - 'output': 'same' - }; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = factory( table, [ dtypes ], policies ); + v = factory( table, [ idtypes ], odtypes ); if ( typeof v !== 'function' ) { b.fail( 'should return a function' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/repl.txt index 46a8428c02e3..4cbdb1caab5c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( table, odtypes, policies[, options] ) +{{alias}}( table, idtypes, odtypes[, options] ) Returns function for applying a strided function to an output ndarray. Parameters @@ -28,14 +28,12 @@ - arrays: array containing an output ndarray, followed by any additional ndarray arguments. - odtypes: Array> - List containing lists of supported output array data types for each - output ndarray argument. + idtypes: Array> + List containing lists of supported input data types for each input + ndarray argument. - policies: Object - Dispatch policies. Must have the following properties: - - - output: output data type policy. + odtypes: Array + List of supported output data types. options: Object (optional) Function options. @@ -51,10 +49,10 @@ Examples -------- - > var dt = [ 'float64', 'float32', 'generic' ]; - > var p = { 'output': 'same' }; + > var idt = [ 'float64', 'float32', 'generic' ]; + > var odt = [ 'float64', 'float32', 'generic' ]; > var t = { 'default': {{alias:@stdlib/blas/ext/base/ndarray/gsorthp}} }; - > var f = {{alias}}( t, [ dt ], p ); + > var f = {{alias}}( t, [ idt ], odt ); fcn.assign( x[, ...args][, options] ) Applies a strided function and assign results to a provided output ndarray. @@ -82,10 +80,10 @@ fcn.assign( x[, ...args][, options] ) Examples -------- - > var dts = [ 'float64', 'float32', 'generic' ]; - > var p = { 'output': 'same' }; + > var idt = [ 'float64', 'float32', 'generic' ]; + > var odt = [ 'float64', 'float32', 'generic' ]; > var t = { 'default': {{alias:@stdlib/blas/ext/base/ndarray/gsorthp}} }; - > var f = {{alias}}( t, [ dts ], p ); + > var f = {{alias}}( t, [ idt ], odt ); > var buf = [ -1.0, 2.0, -3.0, -4.0 ]; > var dt = 'generic'; > var sh = [ buf.length ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/index.d.ts index 6d1c72e61690..4a602ad3867b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/index.d.ts @@ -21,7 +21,7 @@ /// import { ArrayLike } from '@stdlib/types/array'; -import { OutputPolicy, DataType, typedndarray } from '@stdlib/types/ndarray'; +import { DataType, typedndarray } from '@stdlib/types/ndarray'; /** * Input array. @@ -96,15 +96,6 @@ interface DispatchTable extends BaseDispatchTable { fcns: ArrayLike | NullaryWithAdditionalArrays>; } -/** -* Dispatch policies. -*/ -interface Policies { - /** - * Output data type policy. - */ - output: OutputPolicy; -} /** * Interface for applying an operation to an ndarray. @@ -124,20 +115,22 @@ interface NullaryFunction { * var ndarray2array = require( '@stdlib/ndarray/to-array' ); * var ndarray = require( '@stdlib/ndarray/base/ctor' ); * + * var idt = dtypes( 'real_and_generic' ); * var odt = dtypes( 'all' ); - * var policies = { - * 'output': 'same' - * }; * * var table = { * 'default': base * }; - * var sorthp = factory( table, [ odt ], policy ); + * var sorthp = factory( table, [ idt ], odt ); * * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * - * var out = sorthp.assign( x ); + * var o = scalar2ndarray( 1.0, { + * 'dtype': 'generic' + * }); + * + * var out = sorthp.assign( x, o ); * // returns * * var arr = ndarray2array( out ); @@ -163,15 +156,13 @@ interface NullaryFunction { * var ndarray2array = require( '@stdlib/ndarray/to-array' ); * var ndarray = require( '@stdlib/ndarray/base/ctor' ); * + * var idt = dtypes( 'real_and_generic' ); * var odt = dtypes( 'all' ); - * var policies = { - * 'output': 'same' - * }; * * var table = { * 'default': base * }; - * var sorthp = factory( table, [ odt ], policy ); + * var sorthp = factory( table, [ idt ], odt ); * * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); @@ -196,10 +187,10 @@ interface NullaryFunction { * Creates a function for applying a strided function to an output ndarray. * * @param table - dispatch table -* @param odtypes - list containing lists of supported output data types for each ndarray argument -* @param policies - dispatch policies +* @param idtypes - list containing lists of supported input data types for each ndarray argument +* @param odtypes - list of supported output data types * @param options - function options -* @returns function for applying a unary function +* @returns function for applying a nullary function * * @example * var base = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); @@ -208,15 +199,13 @@ interface NullaryFunction { * var ndarray2array = require( '@stdlib/ndarray/to-array' ); * var ndarray = require( '@stdlib/ndarray/base/ctor' ); * +* var idt = dtypes( 'real_and_generic' ); * var odt = dtypes( 'all' ); -* var policies = { -* 'output': 'same' -* }; * * var table = { * 'default': base * }; -* var sorthp = factory( table, [ odt ], policy ); +* var sorthp = factory( table, [ idt ], odt ); * * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); @@ -234,7 +223,7 @@ interface NullaryFunction { * var bool = ( out === x ); * // returns true */ -declare function factory( table: DispatchTable | BaseDispatchTable, odtypes: ArrayLike>, policies: Policies, options?: FactoryOptions ): NullaryFunction; +declare function factory( table: DispatchTable | BaseDispatchTable, idtypes: ArrayLike>, odtypes: ArrayLike, options?: FactoryOptions ): NullaryFunction; // EXPORTS // diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/test.ts index a4f457115326..d4539e7eab78 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/test.ts @@ -20,9 +20,10 @@ /// -import { DataType, OutputPolicy, InputCastingPolicy } from '@stdlib/types/ndarray'; -import cumax = require( '@stdlib/stats/base/ndarray/cumax' ); +import { DataType } from '@stdlib/types/ndarray'; +import gsorthp = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); import zeros = require( '@stdlib/ndarray/zeros' ); +import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); import factory = require( './index' ); @@ -32,352 +33,151 @@ import factory = require( './index' ); { const dtypes: Array = [ 'float64', 'float32' ]; const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy + 'default': gsorthp }; - factory( table, [ dtypes ], dtypes, policies ); // $ExpectType UnaryFunction - factory( table, [ dtypes ], dtypes, policies, {} ); // $ExpectType UnaryFunction + factory( table, [ dtypes ], dtypes ); // $ExpectType NullaryFunction + factory( table, [ dtypes ], dtypes, {} ); // $ExpectType NullaryFunction } // The compiler throws an error if the function is provided a first argument which is not a dispatch table... { const dtypes: Array = [ 'float64', 'float32' ]; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy - }; - factory( '5', [ dtypes ], dtypes, policies ); // $ExpectError - factory( 5, [ dtypes ], dtypes, policies ); // $ExpectError - factory( true, [ dtypes ], dtypes, policies ); // $ExpectError - factory( false, [ dtypes ], dtypes, policies ); // $ExpectError - factory( null, [ dtypes ], dtypes, policies ); // $ExpectError - factory( void 0, [ dtypes ], dtypes, policies ); // $ExpectError - factory( 'abc', [ dtypes ], dtypes, policies ); // $ExpectError - factory( {}, [ dtypes ], dtypes, policies ); // $ExpectError - factory( ( x: number, y: number ): number => x + y, [ dtypes ], dtypes, policies ); // $ExpectError + factory( '5', [ dtypes ], dtypes ); // $ExpectError + factory( 5, [ dtypes ], dtypes ); // $ExpectError + factory( true, [ dtypes ], dtypes ); // $ExpectError + factory( false, [ dtypes ], dtypes ); // $ExpectError + factory( null, [ dtypes ], dtypes ); // $ExpectError + factory( void 0, [ dtypes ], dtypes ); // $ExpectError + factory( 'abc', [ dtypes ], dtypes ); // $ExpectError + factory( {}, [ dtypes ], dtypes ); // $ExpectError + factory( ( x: number, y: number ): number => x + y, [ dtypes ], dtypes ); // $ExpectError - factory( '5', [ dtypes ], dtypes, policies, {} ); // $ExpectError - factory( 5, [ dtypes ], dtypes, policies, {} ); // $ExpectError - factory( true, [ dtypes ], dtypes, policies, {} ); // $ExpectError - factory( false, [ dtypes ], dtypes, policies, {} ); // $ExpectError - factory( null, [ dtypes ], dtypes, policies, {} ); // $ExpectError - factory( void 0, [ dtypes ], dtypes, policies, {} ); // $ExpectError - factory( 'abc', [ dtypes ], dtypes, policies, {} ); // $ExpectError - factory( {}, [ dtypes ], dtypes, policies, {} ); // $ExpectError - factory( ( x: number, y: number ): number => x + y, [ dtypes ], dtypes, policies, {} ); // $ExpectError + factory( '5', [ dtypes ], dtypes, {} ); // $ExpectError + factory( 5, [ dtypes ], dtypes, {} ); // $ExpectError + factory( true, [ dtypes ], dtypes, {} ); // $ExpectError + factory( false, [ dtypes ], dtypes, {} ); // $ExpectError + factory( null, [ dtypes ], dtypes, {} ); // $ExpectError + factory( void 0, [ dtypes ], dtypes, {} ); // $ExpectError + factory( 'abc', [ dtypes ], dtypes, {} ); // $ExpectError + factory( {}, [ dtypes ], dtypes, {} ); // $ExpectError + factory( ( x: number, y: number ): number => x + y, [ dtypes ], dtypes, {} ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a list of data type lists... { const dtypes: Array = [ 'float64', 'float32' ]; const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy + 'default': gsorthp }; - factory( table, '5', dtypes, policies ); // $ExpectError - factory( table, 5, dtypes, policies ); // $ExpectError - factory( table, true, dtypes, policies ); // $ExpectError - factory( table, false, dtypes, policies ); // $ExpectError - factory( table, null, dtypes, policies ); // $ExpectError - factory( table, void 0, dtypes, policies ); // $ExpectError - factory( table, 'abc', dtypes, policies ); // $ExpectError - factory( table, {}, dtypes, policies ); // $ExpectError - factory( table, ( x: number ): number => x, dtypes, policies ); // $ExpectError + factory( table, '5', dtypes ); // $ExpectError + factory( table, 5, dtypes ); // $ExpectError + factory( table, true, dtypes ); // $ExpectError + factory( table, false, dtypes ); // $ExpectError + factory( table, null, dtypes ); // $ExpectError + factory( table, void 0, dtypes ); // $ExpectError + factory( table, 'abc', dtypes ); // $ExpectError + factory( table, {}, dtypes ); // $ExpectError + factory( table, ( x: number ): number => x, dtypes ); // $ExpectError - factory( table, '5', dtypes, policies, {} ); // $ExpectError - factory( table, 5, dtypes, policies, {} ); // $ExpectError - factory( table, true, dtypes, policies, {} ); // $ExpectError - factory( table, false, dtypes, policies, {} ); // $ExpectError - factory( table, null, dtypes, policies, {} ); // $ExpectError - factory( table, void 0, dtypes, policies, {} ); // $ExpectError - factory( table, 'abc', dtypes, policies, {} ); // $ExpectError - factory( table, {}, dtypes, policies, {} ); // $ExpectError - factory( table, ( x: number ): number => x, dtypes, policies, {} ); // $ExpectError + factory( table, '5', dtypes, {} ); // $ExpectError + factory( table, 5, dtypes, {} ); // $ExpectError + factory( table, true, dtypes, {} ); // $ExpectError + factory( table, false, dtypes, {} ); // $ExpectError + factory( table, null, dtypes, {} ); // $ExpectError + factory( table, void 0, dtypes, {} ); // $ExpectError + factory( table, 'abc', dtypes, {} ); // $ExpectError + factory( table, {}, dtypes, {} ); // $ExpectError + factory( table, ( x: number ): number => x, dtypes, {} ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a list of data types... { const dtypes: Array = [ 'float64', 'float32' ]; const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy + 'default': gsorthp }; - factory( table, [ dtypes ], '5', policies ); // $ExpectError - factory( table, [ dtypes ], 5, policies ); // $ExpectError - factory( table, [ dtypes ], true, policies ); // $ExpectError - factory( table, [ dtypes ], false, policies ); // $ExpectError - factory( table, [ dtypes ], null, policies ); // $ExpectError - factory( table, [ dtypes ], void 0, policies ); // $ExpectError - factory( table, [ dtypes ], 'abc', policies ); // $ExpectError - factory( table, [ dtypes ], {}, policies ); // $ExpectError - factory( table, [ dtypes ], ( x: number ): number => x, policies ); // $ExpectError + factory( table, [ dtypes ], '5' ); // $ExpectError + factory( table, [ dtypes ], 5 ); // $ExpectError + factory( table, [ dtypes ], true ); // $ExpectError + factory( table, [ dtypes ], false ); // $ExpectError + factory( table, [ dtypes ], null ); // $ExpectError + factory( table, [ dtypes ], void 0 ); // $ExpectError + factory( table, [ dtypes ], 'abc' ); // $ExpectError + factory( table, [ dtypes ], {} ); // $ExpectError + factory( table, [ dtypes ], ( x: number ): number => x ); // $ExpectError - factory( table, [ dtypes ], '5', policies, {} ); // $ExpectError - factory( table, [ dtypes ], 5, policies, {} ); // $ExpectError - factory( table, [ dtypes ], true, policies, {} ); // $ExpectError - factory( table, [ dtypes ], false, policies, {} ); // $ExpectError - factory( table, [ dtypes ], null, policies, {} ); // $ExpectError - factory( table, [ dtypes ], void 0, policies, {} ); // $ExpectError - factory( table, [ dtypes ], 'abc', policies, {} ); // $ExpectError - factory( table, [ dtypes ], {}, policies, {} ); // $ExpectError - factory( table, [ dtypes ], ( x: number ): number => x, policies, {} ); // $ExpectError + factory( table, [ dtypes ], '5', {} ); // $ExpectError + factory( table, [ dtypes ], 5, {} ); // $ExpectError + factory( table, [ dtypes ], true, {} ); // $ExpectError + factory( table, [ dtypes ], false, {} ); // $ExpectError + factory( table, [ dtypes ], null, {} ); // $ExpectError + factory( table, [ dtypes ], void 0, {} ); // $ExpectError + factory( table, [ dtypes ], 'abc', {} ); // $ExpectError + factory( table, [ dtypes ], {}, {} ); // $ExpectError + factory( table, [ dtypes ], ( x: number ): number => x, {} ); // $ExpectError } -// The compiler throws an error if the function is provided a fourth argument which is not a valid policy object... +// The compiler throws an error if the function is provided a fourth argument which is not an object... { const dtypes: Array = [ 'float64', 'float32' ]; const table = { - 'default': cumax - }; - - factory( table, [ dtypes ], dtypes, '5' ); // $ExpectError - factory( table, [ dtypes ], dtypes, 5 ); // $ExpectError - factory( table, [ dtypes ], dtypes, true ); // $ExpectError - factory( table, [ dtypes ], dtypes, false ); // $ExpectError - factory( table, [ dtypes ], dtypes, null ); // $ExpectError - factory( table, [ dtypes ], dtypes, void 0 ); // $ExpectError - factory( table, [ dtypes ], dtypes, 'abc' ); // $ExpectError - factory( table, [ dtypes ], dtypes, {} ); // $ExpectError - factory( table, [ dtypes ], dtypes, ( x: number ): number => x ); // $ExpectError - - factory( table, [ dtypes ], dtypes, '5', {} ); // $ExpectError - factory( table, [ dtypes ], dtypes, 5, {} ); // $ExpectError - factory( table, [ dtypes ], dtypes, true, {} ); // $ExpectError - factory( table, [ dtypes ], dtypes, false, {} ); // $ExpectError - factory( table, [ dtypes ], dtypes, null, {} ); // $ExpectError - factory( table, [ dtypes ], dtypes, void 0, {} ); // $ExpectError - factory( table, [ dtypes ], dtypes, 'abc', {} ); // $ExpectError - factory( table, [ dtypes ], dtypes, {}, {} ); // $ExpectError - factory( table, [ dtypes ], dtypes, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not an object... -{ - const dtypes: Array = [ 'float64', 'float32' ]; - const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy + 'default': gsorthp }; - factory( table, [ dtypes ], dtypes, policies, '5' ); // $ExpectError - factory( table, [ dtypes ], dtypes, policies, 5 ); // $ExpectError - factory( table, [ dtypes ], dtypes, policies, true ); // $ExpectError - factory( table, [ dtypes ], dtypes, policies, false ); // $ExpectError - factory( table, [ dtypes ], dtypes, policies, null ); // $ExpectError - factory( table, [ dtypes ], dtypes, policies, 'abc' ); // $ExpectError - factory( table, [ dtypes ], dtypes, policies, ( x: number ): number => x ); // $ExpectError + factory( table, [ dtypes ], dtypes, '5' ); // $ExpectError + factory( table, [ dtypes ], dtypes, 5 ); // $ExpectError + factory( table, [ dtypes ], dtypes, true ); // $ExpectError + factory( table, [ dtypes ], dtypes, false ); // $ExpectError + factory( table, [ dtypes ], dtypes, null ); // $ExpectError + factory( table, [ dtypes ], dtypes, 'abc' ); // $ExpectError + factory( table, [ dtypes ], dtypes, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { const dtypes: Array = [ 'float64', 'float32' ]; const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy + 'default': gsorthp }; factory(); // $ExpectError - factory( abs ); // $ExpectError - factory( table, [ dtypes ] ); // $ExpectError - factory( table, [ dtypes ], dtypes, policies, {}, {} ); // $ExpectError -} - -// The function returns a function which returns an ndarray... -{ - const dtypes: Array = [ 'float64', 'float32' ]; - const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy - }; - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - const f = factory( table, [ dtypes ], dtypes, policies ); - f( x ); // $ExpectType OutputArray - f( x, {} ); // $ExpectType OutputArray -} - -// The compiler throws an error if the returned function is provided a first argument which is not an ndarray... -{ - const dtypes: Array = [ 'float64', 'float32' ]; - const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy - }; - - const f = factory( table, [ dtypes ], dtypes, policies ); - f( '5' ); // $ExpectError - f( 5 ); // $ExpectError - f( true ); // $ExpectError - f( false ); // $ExpectError - f( null ); // $ExpectError - f( void 0 ); // $ExpectError - f( {} ); // $ExpectError - f( ( x: number ): number => x ); // $ExpectError - - f( '5', {} ); // $ExpectError - f( 5, {} ); // $ExpectError - f( true, {} ); // $ExpectError - f( false, {} ); // $ExpectError - f( null, {} ); // $ExpectError - f( void 0, {} ); // $ExpectError - f( {}, {} ); // $ExpectError - f( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided an invalid second argument... -{ - const dtypes: Array = [ 'float64', 'float32' ]; - const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy - }; - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - const f = factory( table, [ dtypes ], dtypes, policies ); - f( x, '5' ); // $ExpectError - f( x, true ); // $ExpectError - f( x, false ); // $ExpectError - f( x, null ); // $ExpectError - f( x, [] ); // $ExpectError - f( x, ( x: number ): number => x ); // $ExpectError - - f( x, '5', {} ); // $ExpectError - f( x, true, {} ); // $ExpectError - f( x, false, {} ); // $ExpectError - f( x, null, {} ); // $ExpectError - f( x, [], {} ); // $ExpectError - f( x, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided an invalid `dtype` option... -{ - const dtypes: Array = [ 'float64', 'float32' ]; - const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy - }; - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - const f = factory( table, [ dtypes ], dtypes, policies ); - f( x, { 'dtype': '5' } ); // $ExpectError - f( x, { 'dtype': 5 } ); // $ExpectError - f( x, { 'dtype': true } ); // $ExpectError - f( x, { 'dtype': false } ); // $ExpectError - f( x, { 'dtype': null } ); // $ExpectError - f( x, { 'dtype': [] } ); // $ExpectError - f( x, { 'dtype': {} } ); // $ExpectError - f( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided an invalid `dims` option... -{ - const dtypes: Array = [ 'float64', 'float32' ]; - const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy - }; - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - const f = factory( table, [ dtypes ], dtypes, policies ); - f( x, { 'dims': '5' } ); // $ExpectError - f( x, { 'dims': 5 } ); // $ExpectError - f( x, { 'dims': true } ); // $ExpectError - f( x, { 'dims': false } ); // $ExpectError - f( x, { 'dims': null } ); // $ExpectError - f( x, { 'dims': {} } ); // $ExpectError - f( x, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided an unsupported number of arguments... -{ - const dtypes: Array = [ 'float64', 'float32' ]; - const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy - }; - - const f = factory( table, [ dtypes ], dtypes, policies ); - f(); // $ExpectError + factory( table ); // $ExpectError + factory( table, [ dtypes ] ); // $ExpectError + factory( table, [ dtypes ], dtypes, {}, {} ); // $ExpectError } // The function returns a function having an `assign` method which returns an ndarray... { const dtypes: Array = [ 'float64', 'float32' ]; const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy + 'default': gsorthp }; const x = zeros( [ 2, 2 ], { 'dtype': 'float64' }); + const o = scalar2ndarray( 1.0, { + 'dtype': 'generic' + }); - const f = factory( table, [ dtypes ], dtypes, policies ); - f.assign( x, x ); // $ExpectType float64ndarray + const f = factory( table, [ dtypes ], dtypes ); + f.assign( x, o ); // $ExpectType float64ndarray } // The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... { const dtypes: Array = [ 'float64', 'float32' ]; const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy + 'default': gsorthp }; const x = zeros( [ 2, 2 ], { 'dtype': 'float64' }); - const f = factory( table, [ dtypes ], dtypes, policies ); + const f = factory( table, [ dtypes ], dtypes ); f.assign( '5', x ); // $ExpectError f.assign( 5, x ); // $ExpectError f.assign( true, x ); // $ExpectError @@ -397,77 +197,36 @@ import factory = require( './index' ); f.assign( ( x: number ): number => x, x, {} ); // $ExpectError } -// The compiler throws an error if the `assign` method is provided a second argument which is not an ndarray... -{ - const dtypes: Array = [ 'float64', 'float32' ]; - const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy - }; - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - const f = factory( table, [ dtypes ], dtypes, policies ); - f.assign( x, '5' ); // $ExpectError - f.assign( x, 5 ); // $ExpectError - f.assign( x, true ); // $ExpectError - f.assign( x, false ); // $ExpectError - f.assign( x, null ); // $ExpectError - f.assign( x, void 0 ); // $ExpectError - f.assign( x, ( x: number ): number => x ); // $ExpectError - - f.assign( x, '5', {} ); // $ExpectError - f.assign( x, 5, {} ); // $ExpectError - f.assign( x, true, {} ); // $ExpectError - f.assign( x, false, {} ); // $ExpectError - f.assign( x, null, {} ); // $ExpectError - f.assign( x, void 0, {} ); // $ExpectError - f.assign( x, ( x: number ): number => x, {} ); // $ExpectError -} - // The compiler throws an error if the `assign` method is provided an invalid `dims` option... { const dtypes: Array = [ 'float64', 'float32' ]; const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy + 'default': gsorthp }; const x = zeros( [ 2, 2 ], { 'dtype': 'float64' }); + const o = scalar2ndarray( 1.0, { + 'dtype': 'generic' + }); - const f = factory( table, [ dtypes ], dtypes, policies ); - f.assign( x, x, { 'dims': '5' } ); // $ExpectError - f.assign( x, x, { 'dims': 5 } ); // $ExpectError - f.assign( x, x, { 'dims': true } ); // $ExpectError - f.assign( x, x, { 'dims': false } ); // $ExpectError - f.assign( x, x, { 'dims': null } ); // $ExpectError - f.assign( x, x, { 'dims': {} } ); // $ExpectError - f.assign( x, x, { 'dims': ( x: number ): number => x } ); // $ExpectError + const f = factory( table, [ dtypes ], dtypes ); + f.assign( x, o, { 'dims': '5' } ); // $ExpectError + f.assign( x, o, { 'dims': 5 } ); // $ExpectError + f.assign( x, o, { 'dims': true } ); // $ExpectError + f.assign( x, o, { 'dims': false } ); // $ExpectError + f.assign( x, o, { 'dims': null } ); // $ExpectError + f.assign( x, o, { 'dims': {} } ); // $ExpectError + f.assign( x, o, { 'dims': ( x: number ): number => x } ); // $ExpectError } // The compiler throws an error if the `assign` method is provided an unsupported number of arguments... { const dtypes: Array = [ 'float64', 'float32' ]; const table = { - 'default': cumax - }; - const policies = { - 'output': 'same' as OutputPolicy, - 'casting': 'none' as InputCastingPolicy + 'default': gsorthp }; - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - const f = factory( table, [ dtypes ], dtypes, policies ); + const f = factory( table, [ dtypes ], dtypes ); f.assign(); // $ExpectError - f.assign( x ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js index 2ad078a4e649..2750f7b88543 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js @@ -30,14 +30,10 @@ var ndarray2array = require( '@stdlib/ndarray/to-array' ); var ndarray = require( '@stdlib/ndarray/ctor' ); var factory = require( './../lib' ); -// Define the supported output data types: +// Define the supported input and output data types: +var idt = dtypes( 'real_and_generic' ); var odt = dtypes( 'all' ); -// Define dispatch policies: -var policies = { - 'output': 'same' -}; - // Define a dispatch table: var table = { 'types': [ @@ -52,7 +48,7 @@ var table = { }; // Create an interface for performing an operation: -var sorthp = factory( table, [ odt ], policies ); +var sorthp = factory( table, [ idt ], odt ); // Generate an array of random numbers: var xbuf = discreteUniform( 25, -10, 10, { @@ -68,9 +64,7 @@ var o = scalar2ndarray( 1.0, { }); // Perform operation: -sorthp.assign( x, o, { - 'dims': [ 0 ] -}); +sorthp.assign( x, o ); // Print the results: console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/index.js index 8f8e69ff6b0b..63db4624b567 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/index.js @@ -31,15 +31,13 @@ * var ndarray = require( '@stdlib/ndarray/base/ctor' ); * var factory = require( '@stdlib/ndarray/base/nullary-strided1d-dispatch-factory' ); * +* var idt = dtypes( 'real_and_generic' ); * var odt = dtypes( 'all' ); -* var policies = { -* 'output': 'same' -* }; * * var table = { * 'default': base * }; -* var sorthp = factory( table, [ odt ], policies ); +* var sorthp = factory( table, [ idt ], odt ); * * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js index 1c175f17e28e..117dc93f6e0b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js @@ -33,15 +33,14 @@ var NullaryStrided1dDispatch = require( '@stdlib/ndarray/base/nullary-strided1d- * @param {Function} table.default - default strided function * @param {StringArray} [table.types] - one-dimensional list of ndarray data types describing specialized output ndarray argument signatures * @param {ArrayLikeObject} [table.fcns] - list of strided functions which are specific to specialized output ndarray argument signatures -* @param {ArrayLikeObject} odtypes - list containing lists of supported output data types for each ndarray argument -* @param {Object} policies - policies -* @param {string} policies.output - output data type policy +* @param {ArrayLikeObject} idtypes - list containing lists of supported input data types for each ndarray argument +* @param {StringArray} odtypes - list of supported output data types * @param {Options} [options] - function options * @param {boolean} [options.strictTraversalOrder=false] - boolean specifying whether to require that element traversal match the memory layout of an output ndarray * @throws {TypeError} first argument must be an object having valid properties * @throws {Error} first argument must be an object having valid properties * @throws {TypeError} second argument must be an array containing arrays of supported data types -* @throws {TypeError} third argument must be an object having supported policies +* @throws {TypeError} third argument must be an array of supported data types * @throws {TypeError} options argument must be an object * @throws {TypeError} must provide valid options * @returns {Function} function for applying a strided function an ndarray @@ -53,15 +52,13 @@ var NullaryStrided1dDispatch = require( '@stdlib/ndarray/base/nullary-strided1d- * var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); * var ndarray = require( '@stdlib/ndarray/base/ctor' ); * +* var idt = dtypes( 'real_and_generic' ); * var odt = dtypes( 'all' ); -* var policies = { -* 'output': 'same' -* }; * * var table = { * 'default': base * }; -* var sorthp = factory( table, [ odt ], policies ); +* var sorthp = factory( table, [ idt ], odt ); * * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); @@ -70,7 +67,7 @@ var NullaryStrided1dDispatch = require( '@stdlib/ndarray/base/nullary-strided1d- * 'dtype': 'generic' * }); * -* var out = sorthp( x, o ); +* var out = sorthp.assign( x, o ); * // returns * * var arr = ndarray2array( x ); @@ -79,12 +76,12 @@ var NullaryStrided1dDispatch = require( '@stdlib/ndarray/base/nullary-strided1d- * var bool = ( out === x ); * // returns true */ -function factory( table, odtypes, policies, options ) { +function factory( table, idtypes, odtypes, options ) { var f; if ( arguments.length > 3 ) { - f = new NullaryStrided1dDispatch( table, odtypes, policies, options ); // eslint-disable-line max-len + f = new NullaryStrided1dDispatch( table, idtypes, odtypes, options ); // eslint-disable-line max-len } else { - f = new NullaryStrided1dDispatch( table, odtypes, policies ); + f = new NullaryStrided1dDispatch( table, idtypes, odtypes ); } setReadOnly( assign, 'assign', assign ); return assign; From 1f951f542c6a6710a6b5e10339d5a45a7ed390ba Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 17 Sep 2025 00:25:39 +0500 Subject: [PATCH 3/6] refactor: apply suggestions from code review --- .../benchmark/benchmark.assign.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js index a0599a38e9e8..82e20115208c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js @@ -25,7 +25,6 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var dtypes = require( '@stdlib/array/dtypes' ); var uniform = require( '@stdlib/random/array/uniform' ); -var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); var gsorthp = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); var pkg = require( './../package.json' ).name; @@ -60,9 +59,7 @@ function createBenchmark( len ) { 'dtype': 'float64' }); x = new ndarray( 'float64', x, [ len ], [ 1 ], 0, 'row-major' ); - o = scalar2ndarray( 1.0, { - 'dtype': 'generic' - }); + o = new ndarray( 'generic', [ 1 ], [], [ 1 ], 0, 'row-major' ); return benchmark; @@ -73,18 +70,18 @@ function createBenchmark( len ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { - var o; + var out; var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - o = nullary.assign( x, o ); - if ( typeof o !== 'object' ) { + out = nullary.assign( x, o ); + if ( typeof out !== 'object' ) { b.fail( 'should return an ndarray' ); } } b.toc(); - if ( isnan( o.get( i%len ) ) ) { + if ( isnan( out.get( i%len ) ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); From bc9f7559bf79ae9fe07acab6581012a2203300c5 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 17 Sep 2025 00:47:47 +0500 Subject: [PATCH 4/6] fix: lint error --- .../ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js index 117dc93f6e0b..6f1b7b044ff2 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js @@ -79,7 +79,7 @@ var NullaryStrided1dDispatch = require( '@stdlib/ndarray/base/nullary-strided1d- function factory( table, idtypes, odtypes, options ) { var f; if ( arguments.length > 3 ) { - f = new NullaryStrided1dDispatch( table, idtypes, odtypes, options ); // eslint-disable-line max-len + f = new NullaryStrided1dDispatch( table, idtypes, odtypes, options ); } else { f = new NullaryStrided1dDispatch( table, idtypes, odtypes ); } From 5c6a11dde3c84a6ac2f258dcdc90f66013ee81e3 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 17 Sep 2025 00:56:22 +0500 Subject: [PATCH 5/6] fix: lint error --- .../base/nullary-strided1d-dispatch-factory/examples/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js index 2750f7b88543..45d4a6fcb32d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js @@ -16,8 +16,6 @@ * limitations under the License. */ -/* eslint-disable array-element-newline */ - 'use strict'; var dsorthp = require( '@stdlib/blas/ext/base/ndarray/dsorthp' ); From b04cfebb80666dc9d3886a2b7fec2728b5acd15c Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 17 Sep 2025 02:01:50 -0700 Subject: [PATCH 6/6] chore: clean-up --- 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: passed - task: lint_repl_help status: skipped - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - 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 --- --- .../README.md | 28 ++++---- .../benchmark/benchmark.assign.js | 4 +- .../docs/repl.txt | 10 +-- .../docs/types/index.d.ts | 28 ++++---- .../docs/types/test.ts | 72 ++++++++++--------- .../examples/index.js | 8 +-- .../lib/index.js | 8 +-- .../lib/main.js | 8 +-- .../package.json | 7 +- 9 files changed, 85 insertions(+), 88 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/README.md b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/README.md index 25c114f173e3..431f1e58bf28 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/README.md @@ -20,7 +20,7 @@ limitations under the License. # nullaryStrided1dDispatchFactory -> Create a function for applying a strided function to an output ndarray. +> Create a function for applying a strided function to an ndarray.
@@ -34,7 +34,7 @@ var nullaryStrided1dDispatchFactory = require( '@stdlib/ndarray/base/nullary-str #### nullaryStrided1dDispatchFactory( table, idtypes, odtypes\[, options] ) -Returns a function for applying a strided function to an output ndarray. +Returns a function for applying a strided function to an ndarray. @@ -69,9 +69,9 @@ The function has the following parameters: The function supports the following options: -- **strictTraversalOrder**: boolean specifying whether the order of element traversal must match the memory layout order of an input ndarray. Default: `false`. +- **strictTraversalOrder**: boolean specifying whether the order of element traversal must match the memory layout order of an output ndarray. Default: `false`. -#### unary.assign( x\[, ...args]\[, options] ) +#### nullary( out\[, ...args]\[, options] ) Applies a strided function and assigns results to a provided output ndarray. @@ -95,11 +95,11 @@ var nullary = nullaryStrided1dDispatchFactory( table, [ idt ], odt ); var xbuf = [ -1.0, 2.0, -3.0 ]; var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); -var o = scalar2ndarray( 1.0, { +var order = scalar2ndarray( 1.0, { 'dtype': 'generic' }); -var out = nullary.assign( x, o ); +var out = nullary( x, order ); // returns var arr = ndarray2array( out ); @@ -111,8 +111,8 @@ var bool = ( out === x ); The method has the following parameters: -- **x**: output ndarray. -- **args**: additional output ndarray arguments (_optional_). +- **out**: output ndarray. +- **args**: additional input ndarray arguments (_optional_). - **options**: function options (_optional_). The method accepts the following options: @@ -137,8 +137,6 @@ The method accepts the following options: - **arrays**: array containing an output ndarray, followed by any additional ndarray arguments. -- The output data type policy only applies to the function returned by the main function. For the `assign` method, the output ndarray is allowed to have any supported output data type. -
@@ -147,7 +145,7 @@ The method accepts the following options: ## Examples - + @@ -169,8 +167,8 @@ var odt = dtypes( 'all' ); // Define a dispatch table: var table = { 'types': [ - 'float64', - 'float32' + 'float64', // input/output + 'float32' // input/output ], 'fcns': [ dsorthp, @@ -191,12 +189,12 @@ var xbuf = discreteUniform( 25, -10, 10, { var x = new ndarray( 'generic', xbuf, [ 5, 5 ], [ 5, 1 ], 0, 'row-major' ); console.log( ndarray2array( x ) ); -var o = scalar2ndarray( 1.0, { +var order = scalar2ndarray( 1.0, { 'dtype': 'generic' }); // Perform operation: -sorthp.assign( x, o ); +sorthp( x, order ); // Print the results: console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js index 82e20115208c..9c8ba48c25dd 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/benchmark/benchmark.assign.js @@ -75,7 +75,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - out = nullary.assign( x, o ); + out = nullary( x, o ); if ( typeof out !== 'object' ) { b.fail( 'should return an ndarray' ); } @@ -110,7 +110,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); + bench( pkg+'::assign:len='+len, f ); } } diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/repl.txt index 4cbdb1caab5c..71e2b4c4863a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( table, idtypes, odtypes[, options] ) - Returns function for applying a strided function to an output ndarray. + Returns function for applying a strided function to an ndarray. Parameters ---------- @@ -54,13 +54,13 @@ > var t = { 'default': {{alias:@stdlib/blas/ext/base/ndarray/gsorthp}} }; > var f = {{alias}}( t, [ idt ], odt ); -fcn.assign( x[, ...args][, options] ) +fcn( out[, ...args][, options] ) Applies a strided function and assign results to a provided output ndarray. Parameters ---------- - x: ndarray - Input array. + out: ndarray + Output array. args: ...ndarray (optional) Additional ndarray arguments. @@ -92,7 +92,7 @@ fcn.assign( x[, ...args][, options] ) > var ord = 'row-major'; > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, buf, sh, sx, ox, ord ); > var o = {{alias:@stdlib/ndarray/from-scalar}}( 1.0 ); - > var out = f.assign( x, o ) + > var out = f( x, o ) > var bool = ( out === x ) true diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/index.d.ts index 4a602ad3867b..0b36d8d7f3a6 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/index.d.ts @@ -48,7 +48,7 @@ interface BaseOptions { */ interface FactoryOptions { /** - * Boolean specifying whether the order of element traversal must match the memory layout of an input ndarray. + * Boolean specifying whether the order of element traversal must match the memory layout of an output ndarray. */ strictTraversalOrder?: boolean; } @@ -56,7 +56,7 @@ interface FactoryOptions { /** * Strided function. * -* @param arrays - output ndarrays +* @param arrays - input ndarrays * @param options - function options * @returns result */ @@ -65,7 +65,7 @@ type Nullary = ( arrays: [ typedndarray ], options?: unknown ) => typednda /** * Strided function. * -* @param arrays - output ndarrays +* @param arrays - input ndarrays * @param options - function options * @returns result */ @@ -104,7 +104,7 @@ interface NullaryFunction { /** * Applies a strided function and assign results to a provided output ndarray. * - * @param x - output ndarray + * @param out - output ndarray * @param options - function options * @returns output ndarray * @@ -126,11 +126,11 @@ interface NullaryFunction { * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * - * var o = scalar2ndarray( 1.0, { + * var order = scalar2ndarray( 1.0, { * 'dtype': 'generic' * }); * - * var out = sorthp.assign( x, o ); + * var out = sorthp( x, order ); * // returns * * var arr = ndarray2array( out ); @@ -139,13 +139,13 @@ interface NullaryFunction { * var bool = ( out === x ); * // returns true */ - assign = OutputArray>( x: V, options?: BaseOptions ): V; + = OutputArray>( out: V, options?: BaseOptions ): V; /** * Applies a strided function and assigns results to a provided output ndarray. * - * @param x - input ndarray - * @param o - additional ndarray argument + * @param out - output ndarray + * @param x - additional ndarray argument * @param args - output ndarray, additional array arguments, and function options * @returns output ndarray * @@ -167,11 +167,11 @@ interface NullaryFunction { * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * - * var o = scalar2ndarray( 1.0, { + * var order = scalar2ndarray( 1.0, { * 'dtype': 'generic' * }); * - * var out = sorthp.assign( x, o ); + * var out = sorthp( x, order ); * // returns * * var arr = ndarray2array( out ); @@ -180,7 +180,7 @@ interface NullaryFunction { * var bool = ( out === x ); * // returns true */ - assign = OutputArray>( x: T, ...args: Array ): V; + = OutputArray>( out: V, x: InputArray, ...args: Array ): V; } /** @@ -210,11 +210,11 @@ interface NullaryFunction { * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * -* var o = scalar2ndarray( 1.0, { +* var order = scalar2ndarray( 1.0, { * 'dtype': 'generic' * }); * -* var out = sorthp.assign( x, o ); +* var out = sorthp( x, order ); * // returns * * var arr = ndarray2array( out ); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/test.ts index d4539e7eab78..a3ed9f36b95f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/docs/types/test.ts @@ -150,7 +150,7 @@ import factory = require( './index' ); factory( table, [ dtypes ], dtypes, {}, {} ); // $ExpectError } -// The function returns a function having an `assign` method which returns an ndarray... +// The function returns a function which returns an ndarray... { const dtypes: Array = [ 'float64', 'float32' ]; const table = { @@ -164,40 +164,38 @@ import factory = require( './index' ); }); const f = factory( table, [ dtypes ], dtypes ); - f.assign( x, o ); // $ExpectType float64ndarray + f( x ); // $ExpectType float64ndarray + f( x, o ); // $ExpectType float64ndarray } -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... +// The compiler throws an error if the returned function is provided a first argument which is not an ndarray... { const dtypes: Array = [ 'float64', 'float32' ]; const table = { 'default': gsorthp }; - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); const f = factory( table, [ dtypes ], dtypes ); - f.assign( '5', x ); // $ExpectError - f.assign( 5, x ); // $ExpectError - f.assign( true, x ); // $ExpectError - f.assign( false, x ); // $ExpectError - f.assign( null, x ); // $ExpectError - f.assign( void 0, x ); // $ExpectError - f.assign( {}, x ); // $ExpectError - f.assign( ( x: number ): number => x, x ); // $ExpectError - - f.assign( '5', x, {} ); // $ExpectError - f.assign( 5, x, {} ); // $ExpectError - f.assign( true, x, {} ); // $ExpectError - f.assign( false, x, {} ); // $ExpectError - f.assign( null, x, {} ); // $ExpectError - f.assign( void 0, x, {} ); // $ExpectError - f.assign( {}, x, {} ); // $ExpectError - f.assign( ( x: number ): number => x, x, {} ); // $ExpectError + f( '5' ); // $ExpectError + f( 5 ); // $ExpectError + f( true ); // $ExpectError + f( false ); // $ExpectError + f( null ); // $ExpectError + f( void 0 ); // $ExpectError + f( {} ); // $ExpectError + f( ( x: number ): number => x ); // $ExpectError + + f( '5', {} ); // $ExpectError + f( 5, {} ); // $ExpectError + f( true, {} ); // $ExpectError + f( false, {} ); // $ExpectError + f( null, {} ); // $ExpectError + f( void 0, {} ); // $ExpectError + f( {}, {} ); // $ExpectError + f( ( x: number ): number => x, {} ); // $ExpectError } -// The compiler throws an error if the `assign` method is provided an invalid `dims` option... +// The compiler throws an error if the returned function is provided an invalid `dims` option... { const dtypes: Array = [ 'float64', 'float32' ]; const table = { @@ -211,16 +209,24 @@ import factory = require( './index' ); }); const f = factory( table, [ dtypes ], dtypes ); - f.assign( x, o, { 'dims': '5' } ); // $ExpectError - f.assign( x, o, { 'dims': 5 } ); // $ExpectError - f.assign( x, o, { 'dims': true } ); // $ExpectError - f.assign( x, o, { 'dims': false } ); // $ExpectError - f.assign( x, o, { 'dims': null } ); // $ExpectError - f.assign( x, o, { 'dims': {} } ); // $ExpectError - f.assign( x, o, { 'dims': ( x: number ): number => x } ); // $ExpectError + f( x, { 'dims': '5' } ); // $ExpectError + f( x, { 'dims': 5 } ); // $ExpectError + f( x, { 'dims': true } ); // $ExpectError + f( x, { 'dims': false } ); // $ExpectError + f( x, { 'dims': null } ); // $ExpectError + f( x, { 'dims': {} } ); // $ExpectError + f( x, { 'dims': ( x: number ): number => x } ); // $ExpectError + + f( x, o, { 'dims': '5' } ); // $ExpectError + f( x, o, { 'dims': 5 } ); // $ExpectError + f( x, o, { 'dims': true } ); // $ExpectError + f( x, o, { 'dims': false } ); // $ExpectError + f( x, o, { 'dims': null } ); // $ExpectError + f( x, o, { 'dims': {} } ); // $ExpectError + f( x, o, { 'dims': ( x: number ): number => x } ); // $ExpectError } -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... +// The compiler throws an error if the returned function is provided an unsupported number of arguments... { const dtypes: Array = [ 'float64', 'float32' ]; const table = { @@ -228,5 +234,5 @@ import factory = require( './index' ); }; const f = factory( table, [ dtypes ], dtypes ); - f.assign(); // $ExpectError + f(); // $ExpectError } diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js index 45d4a6fcb32d..740a18102396 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/examples/index.js @@ -35,8 +35,8 @@ var odt = dtypes( 'all' ); // Define a dispatch table: var table = { 'types': [ - 'float64', - 'float32' + 'float64', // input/output + 'float32' // input/output ], 'fcns': [ dsorthp, @@ -57,12 +57,12 @@ var xbuf = discreteUniform( 25, -10, 10, { var x = new ndarray( 'generic', xbuf, [ 5, 5 ], [ 5, 1 ], 0, 'row-major' ); console.log( ndarray2array( x ) ); -var o = scalar2ndarray( 1.0, { +var order = scalar2ndarray( 1.0, { 'dtype': 'generic' }); // Perform operation: -sorthp.assign( x, o ); +sorthp( x, order ); // Print the results: console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/index.js index 63db4624b567..5d3d3f363b7a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Create a function for applying a strided function to an output ndarray. +* Create a function for applying a strided function to a provided ndarray. * * @module @stdlib/ndarray/base/nullary-strided1d-dispatch-factory * @@ -42,11 +42,11 @@ * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * -* var o = scalar2ndarray( 1.0, { +* var order = scalar2ndarray( 1.0, { * 'dtype': 'generic' * }); * -* var out = sorthp.assign( x, o ); +* var out = sorthp( x, order ); * // returns * * var arr = ndarray2array( x ); @@ -64,5 +64,3 @@ var main = require( './main.js' ); // EXPORTS // module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js index 6f1b7b044ff2..ecf3c77fa7de 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/lib/main.js @@ -20,14 +20,13 @@ // MODULES // -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); var NullaryStrided1dDispatch = require( '@stdlib/ndarray/base/nullary-strided1d-dispatch' ); // MAIN // /** -* Returns a function for applying a strided function to an output ndarray. +* Returns a function for applying a strided function to a provided ndarray. * * @param {Object} table - dispatch table * @param {Function} table.default - default strided function @@ -67,7 +66,7 @@ var NullaryStrided1dDispatch = require( '@stdlib/ndarray/base/nullary-strided1d- * 'dtype': 'generic' * }); * -* var out = sorthp.assign( x, o ); +* var out = sorthp( x, o ); * // returns * * var arr = ndarray2array( x ); @@ -83,14 +82,13 @@ function factory( table, idtypes, odtypes, options ) { } else { f = new NullaryStrided1dDispatch( table, idtypes, odtypes ); } - setReadOnly( assign, 'assign', assign ); return assign; /** * Applies a strided function and assigns results to a provided output ndarray. * * @private - * @param {ndarrayLike} x - output ndarray + * @param {ndarrayLike} out - output ndarray * @param {...ndarrayLike} [args] - additional ndarray arguments * @param {Options} [options] - function options * @param {IntegerArray} [options.dims] - list of dimensions over which to perform operation diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/package.json b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/package.json index 755d48fc1e7c..565036eddc99 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/package.json +++ b/lib/node_modules/@stdlib/ndarray/base/nullary-strided1d-dispatch-factory/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/ndarray/base/nullary-strided1d-dispatch-factory", "version": "0.0.0", - "description": "Create a function for applying a strided function to an output ndarray.", + "description": "Create a function for applying a strided function to a provided ndarray.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -59,9 +59,6 @@ "vector", "array", "apply", - "cumulative", - "aggregation", - "aggregate", - "accumulate" + "call" ] }