From fe6de43ec26b9982adbe4a0bb3b91cf4d806c4ca Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 29 Dec 2025 19:00:09 +0500 Subject: [PATCH] refactor: addd writable parameter --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../ndarray/base/expand-dimensions/README.md | 32 ++--- .../expand-dimensions/benchmark/benchmark.js | 4 +- .../benchmark/benchmark.ndims.js | 2 +- .../base/expand-dimensions/docs/repl.txt | 7 +- .../expand-dimensions/docs/types/index.d.ts | 27 +---- .../base/expand-dimensions/docs/types/test.ts | 46 ++++--- .../base/expand-dimensions/examples/index.js | 2 +- .../base/expand-dimensions/lib/index.js | 24 +--- .../base/expand-dimensions/lib/main.js | 38 ++---- .../base/expand-dimensions/test/test.js | 113 +++++++++--------- 10 files changed, 119 insertions(+), 176 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/README.md b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/README.md index 93cefa498433..42e12f428b6b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/README.md @@ -40,7 +40,7 @@ limitations under the License. var expandDimensions = require( '@stdlib/ndarray/base/expand-dimensions' ); ``` -#### expandDimensions( x, axis ) +#### expandDimensions( x, axis, writable ) Expands the shape of an array `x` by inserting a new dimension of size one at a specified `axis`. @@ -49,29 +49,18 @@ var array = require( '@stdlib/ndarray/array' ); // Create a 2x2 ndarray: var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -// returns +// returns [ [ 1, 2 ], [ 3, 4 ] ] // Prepend a singleton dimension: -var y = expandDimensions( x, 0 ); -// returns - -var sh = y.shape; -// returns [ 1, 2, 2 ] - -// Append a singleton dimension: -y = expandDimensions( x, 2 ); -// returns - -sh = y.shape; -// returns [ 2, 2, 1 ] +var y = expandDimensions( x, 0, false ); +// returns [ [ [ 1, 2 ], [ 3, 4 ] ] ] +``` -// Insert a singleton dimension: -y = expandDimensions( x, 1 ); -// returns +The function accepts the following arguments: -sh = y.shape; -// returns [ 2, 1, 2 ] -``` +- **x**: input ndarray. +- **axis**: axis at which to insert a singleton dimension +- **writable**: boolean indicating whether a returned ndarray should be writable. @@ -84,6 +73,7 @@ sh = y.shape; ## Notes - A provided axis must reside on the interval `[-N-1, N]`, where `N` is the rank (i.e., number of dimensions) of the provided input array. If provided a negative `axis`, the axis position at which to insert a singleton dimension is computed as `N + axis + 1`. Hence, if provided `-1`, the resolved axis position is `N` (i.e., a singleton dimension is appended to the input array). +- The `writable` parameter **only** applies to ndarray constructors supporting **read-only** instances. @@ -108,7 +98,7 @@ var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); // returns // Insert a singleton dimension: -var y = expandDimensions( x, 1 ); +var y = expandDimensions( x, 1, false ); // returns // Retrieve the shape: diff --git a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/benchmark/benchmark.js index 690a6a4ea643..326405f76c47 100644 --- a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/benchmark/benchmark.js @@ -59,7 +59,7 @@ bench( pkg+'::base_ndarray,2d', function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - out = expandDimensions( values[ i%values.length ], 1 ); + out = expandDimensions( values[ i%values.length ], 1, false ); if ( typeof out !== 'object' ) { b.fail( 'should return an object' ); } @@ -100,7 +100,7 @@ bench( pkg+'::ndarray,2d', function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - out = expandDimensions( values[ i%values.length ], 1 ); + out = expandDimensions( values[ i%values.length ], 1, false ); if ( typeof out !== 'object' ) { b.fail( 'should return an object' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/benchmark/benchmark.ndims.js b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/benchmark/benchmark.ndims.js index 22f6cd1db66f..46e65bee5654 100644 --- a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/benchmark/benchmark.ndims.js +++ b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/benchmark/benchmark.ndims.js @@ -54,7 +54,7 @@ function createBenchmark( ndims ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - out = expandDimensions( x, i%(ndims-1) ); + out = expandDimensions( x, i%(ndims-1), false ); if ( typeof out !== 'object' ) { b.fail( 'should return an object' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/docs/repl.txt index d67da3cb4f08..7bf733399b7c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( x, axis ) +{{alias}}( x, axis, writable ) Expands the shape of an array by inserting a new dimension of size one at a specified axis. @@ -19,6 +19,9 @@ axis: integer Axis at which to insert a singleton dimension. + writable: boolean + Boolean indicating whether a returned ndarray should be writable. + Returns ------- out: ndarray @@ -30,7 +33,7 @@ > var sh = x.shape [ 2, 2 ] - > var y = {{alias}}( x, 1 ) + > var y = {{alias}}( x, 1, false ) > sh = y.shape [ 2, 1, 2 ] diff --git a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/docs/types/index.d.ts index b6883ebd86d7..99a9141c9184 100644 --- a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/docs/types/index.d.ts @@ -31,36 +31,19 @@ import { ndarray } from '@stdlib/types/ndarray'; * * @param x - input array * @param axis - axis at which to insert a singleton dimension +* @param writable - boolean indicating whether a returned ndarray should be writable * @returns output array * * @example * var array = require( '@stdlib/ndarray/array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns +* // returns [ [ 1, 2 ], [ 3, 4 ] ] * -* var shx = x.shape; -* // returns [ 2, 2 ] -* -* var y = expandDimensions( x, 1 ); -* // returns -* -* var shy = y.shape; -* // returns [ 2, 1, 2 ] -* -* var v = y.get( 0, 0, 0 ); -* // returns 1 -* -* v = y.get( 0, 0, 1 ); -* // returns 2 -* -* v = y.get( 1, 0, 0 ); -* // returns 3 -* -* v = y.get( 1, 0, 1 ); -* // returns 4 +* var y = expandDimensions( x, 1, false ); +* // returns [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ] */ -declare function expandDimensions( x: ndarray, axis: number ): ndarray; +declare function expandDimensions( x: ndarray, axis: number, writable: boolean ): ndarray; // EXPORTS // diff --git a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/docs/types/test.ts index c77ac63d74ce..28e32cfd4f80 100644 --- a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/docs/types/test.ts @@ -26,32 +26,43 @@ import expandDimensions = require( './index' ); { const x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - expandDimensions( x, 1 ); // $ExpectType ndarray + expandDimensions( x, 1, false ); // $ExpectType ndarray } // The compiler throws an error if the function is not provided a first argument which is an ndarray... { - expandDimensions( '5', 1 ); // $ExpectError - expandDimensions( 5, 1 ); // $ExpectError - expandDimensions( true, 1 ); // $ExpectError - expandDimensions( false, 1 ); // $ExpectError - expandDimensions( null, 1 ); // $ExpectError - expandDimensions( {}, 1 ); // $ExpectError - expandDimensions( [ '5' ], 1 ); // $ExpectError - expandDimensions( ( x: number ): number => x, 1 ); // $ExpectError + expandDimensions( '5', 1, false ); // $ExpectError + expandDimensions( 5, 1, false ); // $ExpectError + expandDimensions( true, 1, false ); // $ExpectError + expandDimensions( false, 1, false ); // $ExpectError + expandDimensions( null, 1, false ); // $ExpectError + expandDimensions( {}, 1, false ); // $ExpectError + expandDimensions( [ '5' ], 1, false ); // $ExpectError + expandDimensions( ( x: number ): number => x, 1, false ); // $ExpectError } // The compiler throws an error if the function is not provided a second argument which is a number... { const x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - expandDimensions( x, '5' ); // $ExpectError - expandDimensions( x, true ); // $ExpectError - expandDimensions( x, false ); // $ExpectError - expandDimensions( x, null ); // $ExpectError - expandDimensions( x, {} ); // $ExpectError - expandDimensions( x, [ '5' ] ); // $ExpectError - expandDimensions( x, ( x: number ): number => x ); // $ExpectError + expandDimensions( x, '5', false ); // $ExpectError + expandDimensions( x, true, false ); // $ExpectError + expandDimensions( x, false, false ); // $ExpectError + expandDimensions( x, null, false ); // $ExpectError + expandDimensions( x, {}, false ); // $ExpectError + expandDimensions( x, [ '5' ], false ); // $ExpectError + expandDimensions( x, ( x: number ): number => x, false ); // $ExpectError +} + +// The compiler throws an error if the function is not provided a third argument which is a boolean... +{ + const x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); + + expandDimensions( x, 1, '5' ); // $ExpectError + expandDimensions( x, 1, null ); // $ExpectError + expandDimensions( x, 1, {} ); // $ExpectError + expandDimensions( x, 1, [ '5' ] ); // $ExpectError + expandDimensions( x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -60,5 +71,6 @@ import expandDimensions = require( './index' ); expandDimensions(); // $ExpectError expandDimensions( x ); // $ExpectError - expandDimensions( x, 1, [ 1, 2, 3 ], [ 2, 3 ] ); // $ExpectError + expandDimensions( x, 1 ); // $ExpectError + expandDimensions( x, 1, false, [ 2, 3 ] ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/examples/index.js index ba2fc3a2e6cd..8dc815824819 100644 --- a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/examples/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/examples/index.js @@ -28,7 +28,7 @@ var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); // returns // Insert a singleton dimension: -var y = expandDimensions( x, 1 ); +var y = expandDimensions( x, 1, false ); // returns // Retrieve the shape: diff --git a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/lib/index.js index 6300444724bb..551cb8633be4 100644 --- a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/lib/index.js @@ -28,28 +28,10 @@ * var expandDimensions = require( '@stdlib/ndarray/base/expand-dimensions' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns +* // returns [ [ 1, 2 ], [ 3, 4 ] ] * -* var shx = x.shape; -* // returns [ 2, 2 ] -* -* var y = expandDimensions( x, 1 ); -* // returns -* -* var shy = y.shape; -* // returns [ 2, 1, 2 ] -* -* var v = y.get( 0, 0, 0 ); -* // returns 1 -* -* v = y.get( 0, 0, 1 ); -* // returns 2 -* -* v = y.get( 1, 0, 0 ); -* // returns 3 -* -* v = y.get( 1, 0, 1 ); -* // returns 4 +* var y = expandDimensions( x, 1, false ); +* // returns [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/lib/main.js index 4968bb7c19ab..bb956f9bec16 100644 --- a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/lib/main.js @@ -21,7 +21,6 @@ // MODULES // var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); -var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); var normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); var getDType = require( '@stdlib/ndarray/base/dtype' ); var getShape = require( '@stdlib/ndarray/base/shape' ); @@ -43,6 +42,7 @@ var format = require( '@stdlib/string/format' ); * * @param {ndarray} x - input array * @param {integer} axis - axis at which to insert a singleton dimension +* @param {boolean} writable - boolean indicating whether a returned array should be writable * @throws {RangeError} must provide a valid axis * @returns {ndarray} output array * @@ -50,30 +50,12 @@ var format = require( '@stdlib/string/format' ); * var array = require( '@stdlib/ndarray/array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns +* // returns [ [ 1, 2 ], [ 3, 4 ] ] * -* var shx = x.shape; -* // returns [ 2, 2 ] -* -* var y = expandDimensions( x, 1 ); -* // returns -* -* var shy = y.shape; -* // returns [ 2, 1, 2 ] -* -* var v = y.get( 0, 0, 0 ); -* // returns 1 -* -* v = y.get( 0, 0, 1 ); -* // returns 2 -* -* v = y.get( 1, 0, 0 ); -* // returns 3 -* -* v = y.get( 1, 0, 1 ); -* // returns 4 +* var y = expandDimensions( x, 1, false ); +* // returns [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ] */ -function expandDimensions( x, axis ) { +function expandDimensions( x, axis, writable ) { var strides; var shape; var isrm; @@ -143,13 +125,9 @@ function expandDimensions( x, axis ) { } } } - if ( isReadOnly( x ) ) { - // If provided a read-only view, the returned array should also be read-only... - return new x.constructor( getDType( x ), getData( x ), shape, strides, getOffset( x ), ord, { // eslint-disable-line max-len - 'readonly': true - }); - } - return new x.constructor( getDType( x ), getData( x ), shape, strides, getOffset( x ), ord ); // eslint-disable-line max-len + return new x.constructor( getDType( x ), getData( x ), shape, strides, getOffset( x ), ord, { // eslint-disable-line max-len + 'readonly': !writable + }); } diff --git a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/test/test.js b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/test/test.js index 793431c4f56f..3cca256a0eea 100644 --- a/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/base/expand-dimensions/test/test.js @@ -66,11 +66,19 @@ tape( 'the function prepends singleton dimensions', function test( t ) { x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = expandDimensions( x, 0 ); + y = expandDimensions( x, 0, false ); t.notEqual( y, x, 'returns expected value' ); t.deepEqual( y.shape, [ 1, 2, 2 ], 'returns expected value' ); t.strictEqual( y.data, x.data, 'returns expected value' ); + t.strictEqual( isReadOnly( y ), true, 'returns expected value' ); + + y = expandDimensions( x, 0, true ); + + t.notEqual( y, x, 'returns expected value' ); + t.deepEqual( y.shape, [ 1, 2, 2 ], 'returns expected value' ); + t.strictEqual( y.data, x.data, 'returns expected value' ); + t.strictEqual( isReadOnly( y ), false, 'returns expected value' ); t.end(); }); @@ -81,11 +89,19 @@ tape( 'the function prepends singleton dimensions (negative axis)', function tes x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = expandDimensions( x, -x.ndims-1 ); + y = expandDimensions( x, -x.ndims-1, false ); + + t.notEqual( y, x, 'returns expected value' ); + t.deepEqual( y.shape, [ 1, 2, 2 ], 'returns expected value' ); + t.strictEqual( y.data, x.data, 'returns expected value' ); + t.strictEqual( isReadOnly( y ), true, 'returns expected value' ); + + y = expandDimensions( x, -x.ndims-1, true ); t.notEqual( y, x, 'returns expected value' ); t.deepEqual( y.shape, [ 1, 2, 2 ], 'returns expected value' ); t.strictEqual( y.data, x.data, 'returns expected value' ); + t.strictEqual( isReadOnly( y ), false, 'returns expected value' ); t.end(); }); @@ -96,11 +112,19 @@ tape( 'the function appends singleton dimensions', function test( t ) { x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = expandDimensions( x, x.ndims ); + y = expandDimensions( x, x.ndims, false ); t.notEqual( y, x, 'returns expected value' ); t.deepEqual( y.shape, [ 2, 2, 1 ], 'returns expected value' ); t.strictEqual( y.data, x.data, 'returns expected value' ); + t.strictEqual( isReadOnly( y ), true, 'returns expected value' ); + + y = expandDimensions( x, x.ndims, true ); + + t.notEqual( y, x, 'returns expected value' ); + t.deepEqual( y.shape, [ 2, 2, 1 ], 'returns expected value' ); + t.strictEqual( y.data, x.data, 'returns expected value' ); + t.strictEqual( isReadOnly( y ), false, 'returns expected value' ); t.end(); }); @@ -111,11 +135,19 @@ tape( 'the function appends singleton dimensions (negative axis)', function test x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = expandDimensions( x, -1 ); + y = expandDimensions( x, -1, false ); t.notEqual( y, x, 'returns expected value' ); t.deepEqual( y.shape, [ 2, 2, 1 ], 'returns expected value' ); t.strictEqual( y.data, x.data, 'returns expected value' ); + t.strictEqual( isReadOnly( y ), true, 'returns expected value' ); + + y = expandDimensions( x, x.ndims, true ); + + t.notEqual( y, x, 'returns expected value' ); + t.deepEqual( y.shape, [ 2, 2, 1 ], 'returns expected value' ); + t.strictEqual( y.data, x.data, 'returns expected value' ); + t.strictEqual( isReadOnly( y ), false, 'returns expected value' ); t.end(); }); @@ -126,11 +158,19 @@ tape( 'the function inserts singleton dimensions', function test( t ) { x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = expandDimensions( x, 1 ); + y = expandDimensions( x, 1, false ); t.notEqual( y, x, 'returns expected value' ); t.deepEqual( y.shape, [ 2, 1, 2 ], 'returns expected value' ); t.strictEqual( y.data, x.data, 'returns expected value' ); + t.strictEqual( isReadOnly( y ), true, 'returns expected value' ); + + y = expandDimensions( x, 1, true ); + + t.notEqual( y, x, 'returns expected value' ); + t.deepEqual( y.shape, [ 2, 1, 2 ], 'returns expected value' ); + t.strictEqual( y.data, x.data, 'returns expected value' ); + t.strictEqual( isReadOnly( y ), false, 'returns expected value' ); t.end(); }); @@ -141,11 +181,19 @@ tape( 'the function inserts singleton dimensions (negative axis)', function test x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = expandDimensions( x, -2 ); + y = expandDimensions( x, -2, false ); t.notEqual( y, x, 'returns expected value' ); t.deepEqual( y.shape, [ 2, 1, 2 ], 'returns expected value' ); t.strictEqual( y.data, x.data, 'returns expected value' ); + t.strictEqual( isReadOnly( y ), true, 'returns expected value' ); + + y = expandDimensions( x, -2, true ); + + t.notEqual( y, x, 'returns expected value' ); + t.deepEqual( y.shape, [ 2, 1, 2 ], 'returns expected value' ); + t.strictEqual( y.data, x.data, 'returns expected value' ); + t.strictEqual( isReadOnly( y ), false, 'returns expected value' ); t.end(); }); @@ -329,56 +377,3 @@ tape( 'the function inserts singleton dimensions (base; column-major; negative i t.end(); }); - -tape( 'if provided a read-only array, the function returns a read-only array', function test( t ) { - var x; - var y; - - x = array( [ 1, 2, 3, 4 ], { - 'shape': [ 2, 1, 2 ], - 'readonly': true - }); - - y = expandDimensions( x, 2 ); - - t.notEqual( y, x, 'returns expected value' ); - t.deepEqual( y.shape, [ 2, 1, 1, 2 ], 'returns expected value' ); - t.strictEqual( y.data, x.data, 'returns expected value' ); - t.strictEqual( isReadOnly( y ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided a writable array, the function returns a writable array', function test( t ) { - var x; - var y; - - x = array( [ 1, 2, 3, 4 ], { - 'shape': [ 2, 1, 2 ], - 'readonly': false - }); - - y = expandDimensions( x, 1 ); - - t.notEqual( y, x, 'returns expected value' ); - t.deepEqual( y.shape, [ 2, 1, 1, 2 ], 'returns expected value' ); - t.strictEqual( y.data, x.data, 'returns expected value' ); - t.strictEqual( isReadOnly( y ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided a writable array, the function returns a writable array (base)', function test( t ) { - var x; - var y; - - x = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 1, 2 ], [ 2, 2, 1 ], 0, 'row-major' ); - y = expandDimensions( x, 0 ); - - t.notEqual( y, x, 'returns expected value' ); - t.deepEqual( y.shape, [ 1, 2, 1, 2 ], 'returns expected value' ); - t.strictEqual( y.data, x.data, 'returns expected value' ); - t.strictEqual( isReadOnly( y ), false, 'returns expected value' ); - - t.end(); -});