diff --git a/lib/node_modules/@stdlib/ndarray/base/atleast1d/README.md b/lib/node_modules/@stdlib/ndarray/base/atleast1d/README.md new file mode 100644 index 000000000000..e96b3b59b57b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/atleast1d/README.md @@ -0,0 +1,130 @@ + + +# atleast1d + +> Convert a list of values (scalars and/or ndarrays) to ndarrays having at least one dimension. + +
+ +
+ + + +
+ +## Usage + +```javascript +var atleast1d = require( '@stdlib/ndarray/base/atleast1d' ); +``` + +#### atleast1d( arrays ) + +Converts a list of values (scalars and/or ndarrays) to ndarrays having at least one dimension. + +```javascript +var array = require( '@stdlib/ndarray/array' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + +var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] ); +// returns [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] + +var y = scalar2ndarray( 3.14 ); +// returns [ 3.14 ] + +var out = atleast1d( [ x, y ] ); +// returns [ , ] +``` + +The function accepts the following arguments: + +- **arrays**: array-like object containing a list of scalars and/or ndarrays. + +
+ + + +
+ +## Notes + +- If a provided ndarray has fewer than one dimension, the returned ndarray is a view on the input ndarray data buffer. The view is typically **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to the view may affect multiple elements. If you need to write to the returned ndarray, copy the ndarray **before** performing operations which may mutate elements. + +- The returned ndarray is a "base" [ndarray][@stdlib/ndarray/base/ctor], and, thus, the returned [ndarray][@stdlib/ndarray/base/ctor] does not perform bounds checking or afford any of the guarantees of the non-base [ndarray][@stdlib/ndarray/ctor] constructor. The primary intent of this function is to broadcast an ndarray-like object within internal implementations and to do so with minimal overhead. + +- If provided a scalar value (i.e., a non-ndarray) and that value + + - is a number, the returned ndarray will have the [default][@stdlib/ndarray/defaults] real-valued floating-point data type. + - is a boolean, the returned ndarray will have the [default][@stdlib/ndarray/defaults] boolean data type. + - is a complex number object of a known data type, the data type of the returned ndarray will be the same as the provided value. + - is a complex number object of an unknown data type, the returned ndarray will have the [default][@stdlib/ndarray/defaults] complex-valued floating-point data type. + - is any other value type, the returned ndarray will have a `'generic'` data type. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/discrete-uniform' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var atleast1d = require( '@stdlib/ndarray/base/atleast1d' ); + +var x = discreteUniform( [ 2, 2, 2 ], -100, 100 ); +console.log( ndarray2array( x ) ); + +var y = scalar2ndarray( 3.14 ); +console.log( ndarray2array( y ) ); + +var out = atleast1d( [ x, y ] ); +console.log( ndarray2array( out[ 0 ] ) ); +console.log( ndarray2array( out[ 1 ] ) ); +``` + +
+ + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/base/atleast1d/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/base/atleast1d/benchmark/benchmark.js new file mode 100644 index 000000000000..61266923d9fa --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/atleast1d/benchmark/benchmark.js @@ -0,0 +1,103 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var ndarrayBase = require( '@stdlib/ndarray/base/ctor' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var atleast1d = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::base_ndarray', pkg ), function benchmark( b ) { + var values; + var buffer; + var offset; + var dtype; + var order; + var out; + var i; + + dtype = 'float64'; + buffer = new Float64Array( 12 ); + offset = 0; + order = 'row-major'; + + values = [ + ndarrayBase( dtype, buffer, [ 3, 2, 2 ], [ 4, 2, 1 ], offset, order ), + ndarrayBase( dtype, buffer, [ 4, 3 ], [ 3, 1 ], offset, order ), + ndarrayBase( dtype, buffer, [], [ 0 ], offset, order ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = atleast1d( [ 10.0, values[ i%values.length ] ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isndarrayLike( out[ 0 ] ) || !isndarrayLike( out[ 1 ] ) ) { + b.fail( 'should return an array of ndarrays' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::ndarray', pkg ), function benchmark( b ) { + var values; + var buffer; + var offset; + var dtype; + var order; + var out; + var i; + + dtype = 'float64'; + buffer = new Float64Array( 12 ); + offset = 0; + order = 'row-major'; + + values = [ + ndarray( dtype, buffer, [ 3, 2, 2 ], [ 4, 2, 1 ], offset, order ), + ndarray( dtype, buffer, [ 4, 3 ], [ 3, 1 ], offset, order ), + ndarray( dtype, buffer, [], [ 0 ], offset, order ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = atleast1d( [ 10.0, values[ i%values.length ] ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isndarrayLike( out[ 0 ] ) || !isndarrayLike( out[ 1 ] ) ) { + b.fail( 'should return an array of ndarrays' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/atleast1d/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/atleast1d/docs/repl.txt new file mode 100644 index 000000000000..72bf60f01661 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/atleast1d/docs/repl.txt @@ -0,0 +1,26 @@ + +{{alias}}( arrays ) + Converts a list of values (scalars and/or ndarrays) to ndarrays having at + least one dimension. + + Parameters + ---------- + arrays: ArrayLikeObject + List of scalars and/or ndarrays. + + Returns + ------- + out: Array + List of ndarrays. + + Examples + -------- + > var x = {{alias:@stdlib/ndarray/array}}( [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ] ) + [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ] + > var y = {{alias:@stdlib/ndarray/from-scalar}}( 3.14 ) + [ 3.14 ] + > var out = {{alias}}( [ x, y ] ) + [ , ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/ndarray/base/atleast1d/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/atleast1d/docs/types/index.d.ts new file mode 100644 index 000000000000..e3bdb71f5568 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/atleast1d/docs/types/index.d.ts @@ -0,0 +1,50 @@ +/* +* @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 { ArrayLike } from '@stdlib/types/array'; +import { ndarray } from '@stdlib/types/ndarray'; + +/** +* Converts a list of values (scalars and/or ndarrays) to ndarrays having at least one dimension. +* +* @param arrays - array-like object containing a list of scalars and/or ndarrays +* @returns an array of ndarrays +* +* @example +* var array = require( '@stdlib/ndarray/array' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] ); +* // returns [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] +* +* var y = scalar2ndarray( 3.14 ); +* // returns [ 3.14 ] +* +* var out = atleast1d( [ x, y ] ); +* // returns [ , ] +*/ +declare function atleast1d( arrays: ArrayLike ): Array; + + +// EXPORTS // + +export = atleast1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/atleast1d/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/atleast1d/docs/types/test.ts new file mode 100644 index 000000000000..5bd6881f6a8c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/atleast1d/docs/types/test.ts @@ -0,0 +1,52 @@ +/* +* @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 zeros = require( '@stdlib/ndarray/zeros' ); +import atleast1d = require( './index' ); + + +// TESTS // + +// The function returns an array of ndarrays... +{ + const x = zeros( [ 2, 2 ] ); + const y = zeros( [ 2, 2, 2 ] ); + + atleast1d( [ x ] ); // $ExpectType ndarray[] + atleast1d( [ x, y ] ); // $ExpectType ndarray[] + atleast1d( [ x, y, x ] ); // $ExpectType ndarray[] +} + +// The compiler throws an error if the function is provided a first argument which is not an array... +{ + atleast1d( 5 ); // $ExpectError + atleast1d( true ); // $ExpectError + atleast1d( false ); // $ExpectError + atleast1d( null ); // $ExpectError + atleast1d( {} ); // $ExpectError + atleast1d( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 2, 2 ] ); + const y = zeros( [ 2, 2, 2 ] ); + + atleast1d(); // $ExpectError + atleast1d( [ x, y ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/base/atleast1d/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/atleast1d/examples/index.js new file mode 100644 index 000000000000..28a2fe9f8429 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/atleast1d/examples/index.js @@ -0,0 +1,34 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/discrete-uniform' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var atleast1d = require( './../lib' ); + +var x = discreteUniform( [ 2, 2, 2 ], -100, 100 ); +console.log( ndarray2array( x ) ); + +var y = scalar2ndarray( 3.14 ); +console.log( ndarray2array( y ) ); + +var out = atleast1d( [ x, y ] ); +console.log( ndarray2array( out[ 0 ] ) ); +console.log( ndarray2array( out[ 1 ] ) ); diff --git a/lib/node_modules/@stdlib/ndarray/base/atleast1d/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/atleast1d/lib/index.js new file mode 100644 index 000000000000..477432c8fdff --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/atleast1d/lib/index.js @@ -0,0 +1,48 @@ +/** +* @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'; + +/** +* Convert a list of values (scalars and/or ndarrays) to ndarrays having at least one dimension. +* +* @module @stdlib/ndarray/base/atleast1d +* +* @example +* var array = require( '@stdlib/ndarray/array' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var atleast1d = require( '@stdlib/ndarray/base/atleast1d' ); +* +* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] ); +* // returns [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] +* +* var y = scalar2ndarray( 3.14 ); +* // returns [ 3.14 ] +* +* var out = atleast1d( [ x, y ] ); +* // returns [ , ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/base/atleast1d/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/atleast1d/lib/main.js new file mode 100644 index 000000000000..0a518987f848 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/atleast1d/lib/main.js @@ -0,0 +1,54 @@ +/** +* @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 atleastnd = require( '@stdlib/ndarray/base/atleastnd' ); + + +// MAIN // + +/** +* Converts a list of values (scalars and/or ndarrays) to ndarrays having at least one dimension. +* +* @param {ArrayLikeObject} arrays - array-like object containing a list of scalars and/or ndarrays +* @returns {Array} list of ndarrays +* +* @example +* var array = require( '@stdlib/ndarray/array' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] ); +* // returns [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] +* +* var y = scalar2ndarray( 3.14 ); +* // returns [ 3.14 ] +* +* var out = atleast1d( [ x, y ] ); +* // returns [ , ] +*/ +function atleast1d( arrays ) { + return atleastnd( 1, arrays ); +} + + +// EXPORTS // + +module.exports = atleast1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/atleast1d/package.json b/lib/node_modules/@stdlib/ndarray/base/atleast1d/package.json new file mode 100644 index 000000000000..05c6603f1c51 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/atleast1d/package.json @@ -0,0 +1,63 @@ +{ + "name": "@stdlib/ndarray/base/atleast1d", + "version": "0.0.0", + "description": "Convert a list of values (scalars and/or ndarrays) to ndarrays having at least one dimension.", + "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", + "base", + "strided", + "array", + "ndarray", + "atleast", + "atleast1d", + "broadcast", + "np.atleast_1d" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/ndarray/base/atleast1d/test/test.js b/lib/node_modules/@stdlib/ndarray/base/atleast1d/test/test.js new file mode 100644 index 000000000000..e0390b983b5d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/atleast1d/test/test.js @@ -0,0 +1,124 @@ +/** +* @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 isArray = require( '@stdlib/assert/is-array' ); +var getStrides = require( '@stdlib/ndarray/strides' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var defaults = require( '@stdlib/ndarray/defaults' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var atleast1d = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof atleast1d, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function converts a list of values (scalars and/or ndarrays) to ndarrays having at least one dimension', function test( t ) { + var out; + var x; + var y; + var z; + var w; + var u; + var v; + var s; + + x = zeros( [ 2, 2 ] ); + y = zeros( [] ); + z = 10.0; + w = true; + u = new Complex128( 1.0, 2.0 ); + v = { + 're': 3.0, + 'im': 4.0 + }; + s = 'beep'; + + out = atleast1d( [ x, y, z, w, u, v, s ] ); + + t.strictEqual( isArray( out ), true, 'returns expected value' ); + t.deepEqual( getShape( out[ 0 ] ), [ 2, 2 ], 'returns expected value' ); + t.deepEqual( getShape( out[ 1 ] ), [ 1 ], 'returns expected value' ); + t.deepEqual( getShape( out[ 2 ] ), [ 1 ], 'returns expected value' ); + t.deepEqual( getShape( out[ 3 ] ), [ 1 ], 'returns expected value' ); + t.deepEqual( getShape( out[ 4 ] ), [ 1 ], 'returns expected value' ); + t.deepEqual( getShape( out[ 5 ] ), [ 1 ], 'returns expected value' ); + t.deepEqual( getShape( out[ 6 ] ), [ 1 ], 'returns expected value' ); + t.deepEqual( getStrides( out[ 1 ] ), [ 0 ], 'returns expected value' ); + t.strictEqual( String( getDType( out[ 0 ] ) ), String( getDType( x ) ), 'returns expected value' ); + t.strictEqual( String( getDType( out[ 1 ] ) ), String( getDType( y ) ), 'returns expected value' ); + t.strictEqual( String( getDType( out[ 2 ] ) ), String( defaults.get( 'dtypes.real_floating_point' ) ), 'returns expected value' ); + t.strictEqual( String( getDType( out[ 3 ] ) ), String( defaults.get( 'dtypes.boolean' ) ), 'returns expected value' ); + t.strictEqual( String( getDType( out[ 4 ] ) ), 'complex128', 'returns expected value' ); + t.strictEqual( String( getDType( out[ 5 ] ) ), String( defaults.get( 'dtypes.complex_floating_point' ) ), 'returns expected value' ); + t.strictEqual( String( getDType( out[ 6 ] ) ), 'generic', 'returns expected value' ); + t.strictEqual( out[ 0 ], x, 'returns expected value' ); + t.notEqual( out[ 1 ], y, 'returns expected value' ); + t.notEqual( out[ 2 ], z, 'returns expected value' ); + t.notEqual( out[ 3 ], w, 'returns expected value' ); + t.notEqual( out[ 4 ], u, 'returns expected value' ); + t.notEqual( out[ 5 ], v, 'returns expected value' ); + t.notEqual( out[ 6 ], s, 'returns expected value' ); + t.strictEqual( out[ 0 ] instanceof ndarray, true, 'returns expected value' ); + t.strictEqual( out[ 1 ] instanceof ndarray, true, 'returns expected value' ); + t.strictEqual( out[ 2 ] instanceof ndarray, true, 'returns expected value' ); + t.strictEqual( out[ 3 ] instanceof ndarray, true, 'returns expected value' ); + t.strictEqual( out[ 4 ] instanceof ndarray, true, 'returns expected value' ); + t.strictEqual( out[ 5 ] instanceof ndarray, true, 'returns expected value' ); + t.strictEqual( out[ 6 ] instanceof ndarray, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an ndarray unchanged if an ndarray has at least one dimension', function test( t ) { + var out; + var x; + var y; + var z; + + x = zeros( [ 2 ] ); + y = zeros( [ 3, 2 ] ); + z = zeros( [ 1, 3, 2, 2 ] ); + + out = atleast1d( [ x, y, z ] ); + + t.strictEqual( isArray( out ), true, 'returns expected value' ); + t.deepEqual( getShape( out[ 0 ] ), [ 2 ], 'returns expected value' ); + t.deepEqual( getShape( out[ 1 ] ), [ 3, 2 ], 'returns expected value' ); + t.deepEqual( getShape( out[ 2 ] ), [ 1, 3, 2, 2 ], 'returns expected value' ); + t.strictEqual( out[ 0 ], x, 'returns expected value' ); + t.strictEqual( out[ 1 ], y, 'returns expected value' ); + t.strictEqual( out[ 2 ], z, 'returns expected value' ); + t.strictEqual( out[ 0 ] instanceof ndarray, true, 'returns expected value' ); + t.strictEqual( out[ 1 ] instanceof ndarray, true, 'returns expected value' ); + t.strictEqual( out[ 2 ] instanceof ndarray, true, 'returns expected value' ); + + t.end(); +});