From 848748236ccafb1af3ce7b0eb801d38b0b63f327 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 2 Feb 2026 22:08:37 +0500 Subject: [PATCH 1/2] feat: add ndarray/to-reversed-dimension --- 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: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../ndarray/to-reversed-dimension/README.md | 130 ++++++++ .../benchmark/benchmark.js | 201 ++++++++++++ .../to-reversed-dimension/docs/repl.txt | 34 ++ .../docs/types/index.d.ts | 57 ++++ .../to-reversed-dimension/docs/types/test.ts | 84 +++++ .../to-reversed-dimension/examples/index.js | 29 ++ .../to-reversed-dimension/lib/index.js | 44 +++ .../ndarray/to-reversed-dimension/lib/main.js | 84 +++++ .../to-reversed-dimension/package.json | 66 ++++ .../to-reversed-dimension/test/test.js | 306 ++++++++++++++++++ 10 files changed, 1035 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/to-reversed-dimension/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/to-reversed-dimension/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/to-reversed-dimension/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/to-reversed-dimension/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/to-reversed-dimension/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/README.md b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/README.md new file mode 100644 index 000000000000..d254cd511524 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/README.md @@ -0,0 +1,130 @@ + + +# toReversedDimension + +> Return a new [`ndarray`][@stdlib/ndarray/ctor] where the order of elements of an input [`ndarray`][@stdlib/ndarray/ctor] is reversed. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var toReversedDimension = require( '@stdlib/ndarray/to-reversed-dimension' ); +``` + +#### toReversedDimension( x\[, options] ) + +Returns a new [`ndarray`][@stdlib/ndarray/ctor] where the order of elements of an input [`ndarray`][@stdlib/ndarray/ctor] is reversed. + +```javascript +var array = require( '@stdlib/ndarray/array' ); + +var x = array( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); +// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] + +var y = toReversedDimension( x ); +// returns [ [ 2.0, 1.0 ], [ 4.0, 3.0 ] ] +``` + +The function accepts the following arguments: + +- **x**: input ndarray. +- **options**: function options (_optional_). + +The function supports the following options: + +- **dim**: index of dimension along which to reverse elements. If provided an integer less than zero, the dimension index is resolved relative to the last dimension, with the last dimension corresponding to the value `-1`. Default: `-1`. + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/uniform' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var toReversed = require( '@stdlib/ndarray/to-reversed-dimension' ); + +var x = uniform( [ 3, 3, 3 ], -10.0, 10.0 ); +console.log( ndarray2array( x ) ); + +var y = toReversed( x ); +console.log( ndarray2array( y ) ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/benchmark/benchmark.js new file mode 100644 index 000000000000..ea93ed42237c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/benchmark/benchmark.js @@ -0,0 +1,201 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var empty = require( '@stdlib/ndarray/empty' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var toReversedDimension = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::1d', pkg ), function benchmark( b ) { + var values; + var v; + var i; + + /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ + + values = [ + empty( [ 2 ], { 'dtype': 'float64' } ), + empty( [ 2 ], { 'dtype': 'float32' } ), + empty( [ 2 ], { 'dtype': 'int32' } ), + empty( [ 2 ], { 'dtype': 'complex128' } ), + empty( [ 2 ], { 'dtype': 'generic' } ) + ]; + + /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = toReversedDimension( values[ i%values.length ], { + 'dim': 0 + }); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::2d', pkg ), function benchmark( b ) { + var values; + var v; + var i; + + /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ + + values = [ + empty( [ 2, 2 ], { 'dtype': 'float64' } ), + empty( [ 2, 2 ], { 'dtype': 'float32' } ), + empty( [ 2, 2 ], { 'dtype': 'int32' } ), + empty( [ 2, 2 ], { 'dtype': 'complex128' } ), + empty( [ 2, 2 ], { 'dtype': 'generic' } ) + ]; + + /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = toReversedDimension( values[ i%values.length ], { + 'dim': 0 + }); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::3d', pkg ), function benchmark( b ) { + var values; + var v; + var i; + + /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ + + values = [ + empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), + empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), + empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), + empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), + empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) + ]; + + /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = toReversedDimension( values[ i%values.length ], { + 'dim': 0 + }); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::4d', pkg ), function benchmark( b ) { + var values; + var v; + var i; + + /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ + + values = [ + empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), + empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), + empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), + empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), + empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) + ]; + + /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = toReversedDimension( values[ i%values.length ], { + 'dim': 0 + }); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::5d', pkg ), function benchmark( b ) { + var values; + var v; + var i; + + /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ + + values = [ + empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), + empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), + empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), + empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), + empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) + ]; + + /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = toReversedDimension( values[ i%values.length ], { + 'dim': 0 + }); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/repl.txt new file mode 100644 index 000000000000..4ed2ac36be9d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/repl.txt @@ -0,0 +1,34 @@ + +{{alias}}( x[, options] ) + Returns a new ndarray where the order of elements of an input ndarray is + reversed. + + Parameters + ---------- + x: ndarray + Input array. + + options: object (optional) + Function options. + + options.dim: integer (optional) + Index of dimension along which to reverse elements. If provided an + integer less than zero, the dimension index is resolved relative to the + last dimension, with the last dimension corresponding to the value `-1`. + Default: `-1`. + + Returns + ------- + out: ndarray + Output array. + + Examples + -------- + > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) + [ [ 1, 2 ], [ 3, 4 ] ] + > var y = {{alias}}( x ) + [ [ 2, 1 ], [ 4, 3 ] ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/index.d.ts new file mode 100644 index 000000000000..95f1e7a33178 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/index.d.ts @@ -0,0 +1,57 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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 { ndarray } from '@stdlib/types/ndarray'; + +/** +* Base options. +*/ +interface Options { + /** + * Index of dimension to reverse. + */ + dim?: number; +} + +/** +* Returns a new ndarray where the order of elements of an input ndarray is reversed. +* +* @param x - input array +* @param options - function options +* @param options.dim - index of dimension to reverse +* @returns output array +* +* @example +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); +* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] +* +* var y = toReversedDimension( x ); +* // returns [ [ 2.0, 1.0 ], [ 4.0, 3.0 ] ] +*/ +declare function toReversedDimension( x: T, options?: Options ): T; + + +// EXPORTS // + +export = toReversedDimension; diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/test.ts new file mode 100644 index 000000000000..e7ebe0f19580 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/test.ts @@ -0,0 +1,84 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import empty = require( '@stdlib/ndarray/empty' ); +import toReversedDimension = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + var x = empty( [ 2, 2 ] ); + + toReversedDimension( x ); // $ExpectType float64ndarray + toReversedDimension( x, {} ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an ndarray... +{ + toReversedDimension( '10' ); // $ExpectError + toReversedDimension( 10 ); // $ExpectError + toReversedDimension( false ); // $ExpectError + toReversedDimension( true ); // $ExpectError + toReversedDimension( null ); // $ExpectError + toReversedDimension( [] ); // $ExpectError + toReversedDimension( {} ); // $ExpectError + toReversedDimension( ( x: number ): number => x ); // $ExpectError + + toReversedDimension( '10', {} ); // $ExpectError + toReversedDimension( 10, {} ); // $ExpectError + toReversedDimension( false, {} ); // $ExpectError + toReversedDimension( true, {} ); // $ExpectError + toReversedDimension( null, {} ); // $ExpectError + toReversedDimension( [], {} ); // $ExpectError + toReversedDimension( {}, {} ); // $ExpectError + toReversedDimension( ( x: number ): number => x, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an options argument which is not an object... +{ + const x = empty( [ 2, 2 ] ); + + toReversedDimension( x, '5' ); // $ExpectError + toReversedDimension( x, true ); // $ExpectError + toReversedDimension( x, false ); // $ExpectError + toReversedDimension( x, null ); // $ExpectError + toReversedDimension( x, [ '5' ] ); // $ExpectError + toReversedDimension( x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided a `options.dim` property which is not a number... +{ + const x = empty( [ 2, 2 ] ); + + toReversedDimension( x, { 'dim': '5'} ); // $ExpectError + toReversedDimension( x, { 'dim': true } ); // $ExpectError + toReversedDimension( x, { 'dim': false } ); // $ExpectError + toReversedDimension( x, { 'dim': null } ); // $ExpectError + toReversedDimension( x, { 'dim': [ '5' ] } ); // $ExpectError + toReversedDimension( x, { 'dim': ( x: number ): number => x} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = empty( [ 2, 2 ] ); + + toReversedDimension(); // $ExpectError + toReversedDimension( x, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/examples/index.js b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/examples/index.js new file mode 100644 index 000000000000..e962359ac097 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/examples/index.js @@ -0,0 +1,29 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var uniform = require( '@stdlib/random/uniform' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var toReversedDimension = require( './../lib' ); + +var x = uniform( [ 3, 3, 3 ], -10.0, 10.0 ); +console.log( ndarray2array( x ) ); + +var y = toReversedDimension( x ); +console.log( ndarray2array( y ) ); diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/index.js b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/index.js new file mode 100644 index 000000000000..9958c874dc9a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/index.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +/** +* Return a new ndarray where the order of elements of an input ndarray is reversed along a specified dimension. +* +* @module @stdlib/ndarray/to-reversed-dimension +* +* @example +* var array = require( '@stdlib/ndarray/array' ); +* var toReversedDimension = require( '@stdlib/ndarray/to-reversed-dimension' ); +* +*var x = array( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); +* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] +* +* var y = toReversedDimension( x ); +* // returns [ [ 2.0, 1.0 ], [ 4.0, 3.0 ] ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/main.js b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/main.js new file mode 100644 index 000000000000..3b681991b25c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/main.js @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); +var base = require( '@stdlib/ndarray/base/to-reversed-dimension' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var isObject = require( '@stdlib/assert/is-plain-object' ); +var isInteger = require( '@stdlib/assert/is-integer' ); +var format = require( '@stdlib/string/format' ); +var ndims = require( '@stdlib/ndarray/ndims' ); + + +// MAIN // + +/** +* Returns a new ndarray where the order of elements of an input ndarray is reversed. +* +* @param {ndarray} x - input array +* @param {Object} options - function options +* @param {integer} options.dim - index of dimension to reverse +* @throws {TypeError} first argument must be an ndarray +* @throws {TypeError} options argument must be an object +* @returns {ndarray} output array +* +* @example +* var array = require( '@stdlib/ndarray/array' ); +* +*var x = array( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); +* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] +* +* var y = toReversedDimension( x ); +* // returns [ [ 2.0, 1.0 ], [ 4.0, 3.0 ] ] +*/ +function toReversedDimension( x, options ) { + var opts; + var d; + var N; + + if ( !isndarrayLike( x ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); + } + N = ndims( x ); + opts = { + 'dim': -1 + }; + if ( arguments.length > 1 ) { + if ( !isObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + if ( hasOwnProp( options, 'dim' ) ) { + if ( !isInteger( options.dim ) ) { + throw new TypeError( format( 'invalid option. `%s` option must be an integer. Option: `%s`.', 'dim', options.dim ) ); + } + opts.dim = options.dim; + } + } + d = normalizeIndex( opts.dim, N-1 ); + return base( x, d ); +} + + +// EXPORTS // + +module.exports = toReversedDimension; diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/package.json b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/package.json new file mode 100644 index 000000000000..8754189a4190 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/ndarray/to-reversed-dimension", + "version": "0.0.0", + "description": "Return a new ndarray where the order of elements of an input ndarray is reversed.", + "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", + "stdtypes", + "types", + "base", + "data", + "structure", + "vector", + "ndarray", + "matrix", + "reverse", + "dimension", + "flip", + "numpy.flip" + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/test/test.js b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/test/test.js new file mode 100644 index 000000000000..9cb8d80fb19a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/test/test.js @@ -0,0 +1,306 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var empty = require( '@stdlib/ndarray/empty' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); +var ndims = require( '@stdlib/ndarray/base/ndims' ); +var getDType = require( '@stdlib/ndarray/base/dtype' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var getShape = require( '@stdlib/ndarray/base/shape' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var toReversedDimension = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof toReversedDimension, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toReversedDimension( value ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toReversedDimension( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { + var values; + var x; + var i; + + x = empty( [ 2, 2 ] ); + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toReversedDimension( x, value ); + }; + } +}); + +tape( 'the function returns an error if provided a `dim` option which is not an integer', function test( t ) { + var values; + var x; + var i; + + x = empty( [ 2, 2 ] ); + values = [ + '5', + -3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toReversedDimension( x, { + 'dim': value + }); + }; + } +}); + +tape( 'the function returns a new ndarray where the order of elements of an input ndarray is reversed (ndims=1)', function test( t ) { + var expected; + var actual; + var x; + + x = array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = toReversedDimension( x ); + expected = [ 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ]; + + t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); + t.strictEqual( ndims( actual ), 1, 'returns expected value' ); + t.strictEqual( numel( getShape( actual ) ), 6, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), String( getDType( x ) ), 'returns expected value' ); + t.notEqual( getData( actual ), getData( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + actual = toReversedDimension( x, { + 'dim': -1 + }); + + t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); + t.strictEqual( ndims( actual ), 1, 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 6 ], 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), String( getDType( x ) ), 'returns expected value' ); + t.notEqual( getData( actual ), getData( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a new ndarray where the order of elements of an input ndarray is reversed (ndims=2)', function test( t ) { + var expected; + var actual; + var x; + + x = array( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] ); + + actual = toReversedDimension( x ); + expected = [ [ 2.0, 1.0 ], [ 4.0, 3.0 ], [ 6.0, 5.0 ] ]; + + t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); + t.strictEqual( ndims( actual ), 2, 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 3, 2 ], 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), String( getDType( x ) ), 'returns expected value' ); + t.notEqual( getData( actual ), getData( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + actual = toReversedDimension( x, { + 'dim': -2 + }); + expected = [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]; + + t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); + t.strictEqual( ndims( actual ), 2, 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 3, 2 ], 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), String( getDType( x ) ), 'returns expected value' ); + t.notEqual( getData( actual ), getData( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a new ndarray where the order of elements of an input ndarray is reversed (ndims=3)', function test( t ) { + var expected; + var actual; + var x; + + x = array([ + [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ] + ], + [ + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + ]); + + actual = toReversedDimension( x ); + expected = [ + [ + [ 2.0, 1.0 ], + [ 4.0, 3.0 ] + ], + [ + [ 6.0, 5.0 ], + [ 8.0, 7.0 ] + ] + ]; + + t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); + t.strictEqual( ndims( actual ), 3, 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 2, 2, 2 ], 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), String( getDType( x ) ), 'returns expected value' ); + t.notEqual( getData( actual ), getData( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + actual = toReversedDimension( x, { + 'dim': -2 + }); + expected = [ + [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ], + [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ] + ] + ]; + + t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); + t.strictEqual( ndims( actual ), 3, 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 2, 2, 2 ], 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), String( getDType( x ) ), 'returns expected value' ); + t.notEqual( getData( actual ), getData( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + actual = toReversedDimension( x, { + 'dim': -3 + }); + expected = [ + [ + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ], + [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ] + ] + ]; + + t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' ); + t.strictEqual( ndims( actual ), 3, 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 2, 2, 2 ], 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), String( getDType( x ) ), 'returns expected value' ); + t.notEqual( getData( actual ), getData( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); From 91c25630cf41393cf29d76b27ea7f62500889bb4 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 26 Feb 2026 23:13:27 -0800 Subject: [PATCH 2/2] 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: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../ndarray/to-reversed-dimension/README.md | 10 ++-- .../to-reversed-dimension/docs/repl.txt | 4 +- .../docs/types/index.d.ts | 6 +-- .../to-reversed-dimension/docs/types/test.ts | 3 +- .../to-reversed-dimension/lib/index.js | 2 +- .../ndarray/to-reversed-dimension/lib/main.js | 24 ++++++---- .../to-reversed-dimension/package.json | 3 +- .../to-reversed-dimension/test/test.js | 46 +++++++++++++++++-- 8 files changed, 70 insertions(+), 28 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/README.md b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/README.md index d254cd511524..900d0e0b9dcc 100644 --- a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/README.md +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/README.md @@ -20,7 +20,7 @@ limitations under the License. # toReversedDimension -> Return a new [`ndarray`][@stdlib/ndarray/ctor] where the order of elements of an input [`ndarray`][@stdlib/ndarray/ctor] is reversed. +> Return a new [ndarray][@stdlib/ndarray/ctor] where the order of elements of an input [ndarray][@stdlib/ndarray/ctor] along a specified dimension is reversed. @@ -42,7 +42,7 @@ var toReversedDimension = require( '@stdlib/ndarray/to-reversed-dimension' ); #### toReversedDimension( x\[, options] ) -Returns a new [`ndarray`][@stdlib/ndarray/ctor] where the order of elements of an input [`ndarray`][@stdlib/ndarray/ctor] is reversed. +Returns a new [ndarray][@stdlib/ndarray/ctor] where the order of elements of an input [ndarray][@stdlib/ndarray/ctor] along a specified dimension is reversed. ```javascript var array = require( '@stdlib/ndarray/array' ); @@ -56,7 +56,7 @@ var y = toReversedDimension( x ); The function accepts the following arguments: -- **x**: input ndarray. +- **x**: input [ndarray][@stdlib/ndarray/ctor]. - **options**: function options (_optional_). The function supports the following options: @@ -86,12 +86,12 @@ The function supports the following options: ```javascript var uniform = require( '@stdlib/random/uniform' ); var ndarray2array = require( '@stdlib/ndarray/to-array' ); -var toReversed = require( '@stdlib/ndarray/to-reversed-dimension' ); +var toReversedDimension = require( '@stdlib/ndarray/to-reversed-dimension' ); var x = uniform( [ 3, 3, 3 ], -10.0, 10.0 ); console.log( ndarray2array( x ) ); -var y = toReversed( x ); +var y = toReversedDimension( x ); console.log( ndarray2array( y ) ); ``` diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/repl.txt index 4ed2ac36be9d..712dcc68ed2f 100644 --- a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( x[, options] ) - Returns a new ndarray where the order of elements of an input ndarray is - reversed. + Returns a new ndarray where the order of elements of an input ndarray along + a specified dimension is reversed. Parameters ---------- diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/index.d.ts index 95f1e7a33178..c73dca03cec5 100644 --- a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/index.d.ts @@ -23,17 +23,17 @@ import { ndarray } from '@stdlib/types/ndarray'; /** -* Base options. +* Interface describing function options. */ interface Options { /** - * Index of dimension to reverse. + * Index of dimension to reverse. Default: `-1`. */ dim?: number; } /** -* Returns a new ndarray where the order of elements of an input ndarray is reversed. +* Returns a new ndarray where the order of elements of an input ndarray along a specified dimension is reversed. * * @param x - input array * @param options - function options diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/test.ts index e7ebe0f19580..070dd699d169 100644 --- a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/docs/types/test.ts @@ -63,7 +63,7 @@ import toReversedDimension = require( './index' ); toReversedDimension( x, ( x: number ): number => x ); // $ExpectError } -// The compiler throws an error if the function is provided a `options.dim` property which is not a number... +// The compiler throws an error if the function is provided a `dim` option which is not a number... { const x = empty( [ 2, 2 ] ); @@ -72,6 +72,7 @@ import toReversedDimension = require( './index' ); toReversedDimension( x, { 'dim': false } ); // $ExpectError toReversedDimension( x, { 'dim': null } ); // $ExpectError toReversedDimension( x, { 'dim': [ '5' ] } ); // $ExpectError + toReversedDimension( x, { 'dim': {} } ); // $ExpectError toReversedDimension( x, { 'dim': ( x: number ): number => x} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/index.js b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/index.js index 9958c874dc9a..808a928e1994 100644 --- a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Return a new ndarray where the order of elements of an input ndarray is reversed along a specified dimension. +* Return a new ndarray where the order of elements of an input ndarray along a specified dimension is reversed. * * @module @stdlib/ndarray/to-reversed-dimension * diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/main.js b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/main.js index 3b681991b25c..52b944696af7 100644 --- a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/lib/main.js @@ -20,26 +20,28 @@ // MODULES // -var normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); -var base = require( '@stdlib/ndarray/base/to-reversed-dimension' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); var isObject = require( '@stdlib/assert/is-plain-object' ); var isInteger = require( '@stdlib/assert/is-integer' ); -var format = require( '@stdlib/string/format' ); +var normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); +var base = require( '@stdlib/ndarray/base/to-reversed-dimension' ); var ndims = require( '@stdlib/ndarray/ndims' ); +var format = require( '@stdlib/string/format' ); // MAIN // /** -* Returns a new ndarray where the order of elements of an input ndarray is reversed. +* Returns a new ndarray where the order of elements of an input ndarray along a specified dimension is reversed. * -* @param {ndarray} x - input array -* @param {Object} options - function options -* @param {integer} options.dim - index of dimension to reverse +* @param {ndarrayLike} x - input array +* @param {Object} [options] - function options +* @param {integer} [options.dim=-1] - index of dimension to reverse * @throws {TypeError} first argument must be an ndarray * @throws {TypeError} options argument must be an object +* @throws {TypeError} must provide valid options +* @throws {RangeError} `dim` option is out-of-bounds * @returns {ndarray} output array * * @example @@ -53,13 +55,11 @@ var ndims = require( '@stdlib/ndarray/ndims' ); */ function toReversedDimension( x, options ) { var opts; - var d; var N; - + var d; if ( !isndarrayLike( x ) ) { throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); } - N = ndims( x ); opts = { 'dim': -1 }; @@ -74,7 +74,11 @@ function toReversedDimension( x, options ) { opts.dim = options.dim; } } + N = ndims( x ); d = normalizeIndex( opts.dim, N-1 ); + if ( d === -1 ) { + throw new RangeError( format( 'invalid option. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, d ) ); + } return base( x, d ); } diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/package.json b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/package.json index 8754189a4190..12d04f978f01 100644 --- a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/package.json +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/ndarray/to-reversed-dimension", "version": "0.0.0", - "description": "Return a new ndarray where the order of elements of an input ndarray is reversed.", + "description": "Return a new ndarray where the order of elements of an input ndarray along a specified dimension is reversed.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -52,7 +52,6 @@ "stdlib", "stdtypes", "types", - "base", "data", "structure", "vector", diff --git a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/test/test.js b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/test/test.js index 9cb8d80fb19a..8bda759641c2 100644 --- a/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/to-reversed-dimension/test/test.js @@ -129,7 +129,7 @@ tape( 'the function throws an error if provided an options argument which is not } }); -tape( 'the function returns an error if provided a `dim` option which is not an integer', function test( t ) { +tape( 'the function throws an error if provided a `dim` option which is not an integer', function test( t ) { var values; var x; var i; @@ -162,7 +162,45 @@ tape( 'the function returns an error if provided a `dim` option which is not an } }); -tape( 'the function returns a new ndarray where the order of elements of an input ndarray is reversed (ndims=1)', function test( t ) { +tape( 'the function throws an error if provided a `dim` option which is out-of-bounds', function test( t ) { + var values; + var x; + var i; + + x = empty( [ 2, 2 ] ); + values = [ + -4, + -3, + 2, + 3, + 4 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toReversedDimension( x, { + 'dim': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a zero-dimensional ndarray', function test( t ) { + var x = empty( [] ); + t.throws( badValue, RangeError, 'throws an error' ); + t.end(); + + function badValue() { + toReversedDimension( x ); + } +}); + +tape( 'the function returns a new ndarray where the order of elements of an input ndarray along a specified dimension is reversed (ndims=1)', function test( t ) { var expected; var actual; var x; @@ -193,7 +231,7 @@ tape( 'the function returns a new ndarray where the order of elements of an inpu t.end(); }); -tape( 'the function returns a new ndarray where the order of elements of an input ndarray is reversed (ndims=2)', function test( t ) { +tape( 'the function returns a new ndarray where the order of elements of an input ndarray along a specified dimension is reversed (ndims=2)', function test( t ) { var expected; var actual; var x; @@ -225,7 +263,7 @@ tape( 'the function returns a new ndarray where the order of elements of an inpu t.end(); }); -tape( 'the function returns a new ndarray where the order of elements of an input ndarray is reversed (ndims=3)', function test( t ) { +tape( 'the function returns a new ndarray where the order of elements of an input ndarray along a specified dimension is reversed (ndims=3)', function test( t ) { var expected; var actual; var x;