From d3b7c02cd99c3bd334acb608fb6973ba2916ff21 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 19 Sep 2023 19:57:39 +0000 Subject: [PATCH] Update artifacts --- ndarray/ctor/copy_array.js.html | 247 ++++ ndarray/ctor/coverage.ndjson | 1 + ndarray/ctor/get.js.html | 304 +++++ ndarray/ctor/iget.js.html | 280 +++++ ndarray/ctor/index.html | 221 ++++ ndarray/ctor/index.js.html | 217 ++++ ndarray/ctor/iset.js.html | 301 +++++ ndarray/ctor/main.js.html | 1060 +++++++++++++++++ ndarray/ctor/set.js.html | 325 +++++ ndarray/ctor/validate.js.html | 364 ++++++ ndarray/fancy/array_options.js.html | 2 +- ndarray/fancy/coverage.ndjson | 1 + ndarray/fancy/empty.js.html | 2 +- ndarray/fancy/get.0d.js.html | 2 +- ndarray/fancy/get.1d.js.html | 2 +- ndarray/fancy/get.nd.js.html | 2 +- ndarray/fancy/has_property.js.html | 2 +- ndarray/fancy/index.html | 2 +- ndarray/fancy/index.js.html | 2 +- ndarray/fancy/main.js.html | 2 +- ndarray/fancy/nonreduced_dimensions.js.html | 2 +- ndarray/fancy/re_integer.js.html | 2 +- ndarray/fancy/re_subseq.js.html | 2 +- ndarray/fancy/slice_start.js.html | 2 +- ndarray/fancy/slice_strides.js.html | 2 +- ndarray/fancy/view.1d.js.html | 2 +- ndarray/fancy/view.nd.js.html | 2 +- .../fancy/wrap_multislice_arguments.js.html | 2 +- 28 files changed, 3338 insertions(+), 17 deletions(-) create mode 100644 ndarray/ctor/copy_array.js.html create mode 100644 ndarray/ctor/coverage.ndjson create mode 100644 ndarray/ctor/get.js.html create mode 100644 ndarray/ctor/iget.js.html create mode 100644 ndarray/ctor/index.html create mode 100644 ndarray/ctor/index.js.html create mode 100644 ndarray/ctor/iset.js.html create mode 100644 ndarray/ctor/main.js.html create mode 100644 ndarray/ctor/set.js.html create mode 100644 ndarray/ctor/validate.js.html diff --git a/ndarray/ctor/copy_array.js.html b/ndarray/ctor/copy_array.js.html new file mode 100644 index 000000000..d9aefc34e --- /dev/null +++ b/ndarray/ctor/copy_array.js.html @@ -0,0 +1,247 @@ + + + + + + Code coverage report for ndarray/ctor/lib/copy_array.js + + + + + + + + + +
+
+

All files / ndarray/ctor/lib copy_array.js

+
+ +
+ 100% + Statements + 54/54 +
+ + +
+ 100% + Branches + 3/3 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 54/54 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +5534x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +1372x +1372x +1372x +1372x +1372x +1372x +1003916x +1003916x +1372x +1372x +34x +34x +34x +34x +34x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2018 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';
+ 
+// MAIN //
+ 
+/**
+* Copies the contents of array-like value to a new array.
+*
+* @private
+* @param {ArrayLike} arr - input array
+* @param {NonNegativeInteger} len - array length
+* @returns {Array} output array
+*
+* @example
+* var arr = [ 1.0, 2.0, 3.0 ];
+*
+* var out = copy( arr, arr.length );
+* // returns [ 1.0, 2.0, 3.0 ]
+*
+* var bool = ( arr === out );
+* // returns false
+*/
+function copy( arr, len ) {
+	var out;
+	var i;
+ 
+	out = [];
+	for ( i = 0; i < len; i++ ) {
+		out.push( arr[ i ] );
+	}
+	return out;
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = copy;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/ctor/coverage.ndjson b/ndarray/ctor/coverage.ndjson new file mode 100644 index 000000000..a48372164 --- /dev/null +++ b/ndarray/ctor/coverage.ndjson @@ -0,0 +1 @@ +[801,806,99.3797,109,112,97.3214,7,7,100,801,806,99.3797,"d64f3c7831c6490eae291c9de253dfc763052fbb","2023-09-19 12:54:22 -0700"] diff --git a/ndarray/ctor/get.js.html b/ndarray/ctor/get.js.html new file mode 100644 index 000000000..22fe98c55 --- /dev/null +++ b/ndarray/ctor/get.js.html @@ -0,0 +1,304 @@ + + + + + + Code coverage report for ndarray/ctor/lib/get.js + + + + + + + + + +
+
+

All files / ndarray/ctor/lib get.js

+
+ +
+ 100% + Statements + 73/73 +
+ + +
+ 100% + Branches + 11/11 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 73/73 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +7433x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +993x +993x +993x +993x +993x +993x +993x +11x +11x +982x +982x +993x +2505x +150x +150x +2355x +2355x +2355x +993x +40x +40x +680x +993x +33x +33x +33x +33x +33x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2018 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 no-invalid-this */
+ 
+'use strict';
+ 
+// MODULES //
+ 
+var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive;
+var getIndex = require( '@stdlib/ndarray/base/ind' );
+var format = require( '@stdlib/string/format' );
+ 
+ 
+// MAIN //
+ 
+/**
+* Returns an array element.
+*
+* ## Notes
+*
+* -   The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.
+*
+* @private
+* @param {...integer} [idx] - indices
+* @throws {TypeError} provided indices must be integer valued
+* @throws {RangeError} index exceeds array dimensions
+* @throws {RangeError} number of indices must equal the number of dimensions
+* @returns {*} array element
+*/
+function get() {
+	var idx;
+	var ind;
+	var M;
+	var i;
+ 
+	if ( arguments.length !== this._ndims ) {
+		throw new RangeError( format( 'invalid arguments. Number of indices must match the number of dimensions. ndims: `%u`. nargs: `%u`.', this._ndims, arguments.length ) );
+	}
+	idx = this._offset;
+	M = this._submode.length;
+	for ( i = 0; i < arguments.length; i++ ) {
+		if ( !isInteger( arguments[ i ] ) ) {
+			throw new TypeError( format( 'invalid argument. Indices must be integer valued. Argument: `%u`. Value: `%s`.', i, arguments[ i ] ) );
+		}
+		ind = getIndex( arguments[ i ], this._shape[ i ]-1, this._submode[ i%M ] ); // eslint-disable-line max-len
+		idx += this._strides[ i ] * ind;
+	}
+	if ( this._accessors ) {
+		return this._buffer.get( idx );
+	}
+	return this._buffer[ idx ];
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = get;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/ctor/iget.js.html b/ndarray/ctor/iget.js.html new file mode 100644 index 000000000..d66d9bb98 --- /dev/null +++ b/ndarray/ctor/iget.js.html @@ -0,0 +1,280 @@ + + + + + + Code coverage report for ndarray/ctor/lib/iget.js + + + + + + + + + +
+
+

All files / ndarray/ctor/lib iget.js

+
+ +
+ 100% + Statements + 65/65 +
+ + +
+ 100% + Branches + 6/6 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 65/65 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +6633x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +1605x +1605x +1600x +50x +50x +1550x +1550x +1550x +5x +1605x +33x +33x +33x +33x +33x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2018 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 no-invalid-this */
+ 
+'use strict';
+ 
+// MODULES //
+ 
+var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive;
+var getIndex = require( '@stdlib/ndarray/base/ind' );
+var parent = require( '@stdlib/ndarray/base/ctor' ); // eslint-disable-line stdlib/no-redeclare
+var format = require( '@stdlib/string/format' );
+ 
+ 
+// VARIABLES //
+ 
+var base = parent.prototype.iget;
+ 
+ 
+// MAIN //
+ 
+/**
+* Returns an array element located at a specified linear index.
+*
+* ## Notes
+*
+* -   For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.
+*
+* @private
+* @param {integer} [idx] - linear view index
+* @throws {TypeError} index must be an integer
+* @throws {RangeError} index exceeds array dimensions
+* @returns {*} array element
+*/
+function iget( idx ) {
+	if ( this._ndims > 0 ) {
+		if ( !isInteger( idx ) ) {
+			throw new TypeError( format( 'invalid argument. Index must be an integer. Value: `%s`.', idx ) );
+		}
+		idx = getIndex( idx, this._length-1, this._mode );
+		return base.call( this, idx );
+	}
+	return base.call( this );
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = iget;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/ctor/index.html b/ndarray/ctor/index.html new file mode 100644 index 000000000..f24c33317 --- /dev/null +++ b/ndarray/ctor/index.html @@ -0,0 +1,221 @@ + + + + + + Code coverage report for ndarray/ctor/lib + + + + + + + + + +
+
+

All files ndarray/ctor/lib

+
+ +
+ 99.37% + Statements + 801/806 +
+ + +
+ 97.32% + Branches + 109/112 +
+ + +
+ 100% + Functions + 7/7 +
+ + +
+ 99.37% + Lines + 801/806 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
copy_array.js +
+
100%54/54100%3/3100%1/1100%54/54
get.js +
+
100%73/73100%11/11100%1/1100%73/73
iget.js +
+
100%65/65100%6/6100%1/1100%65/65
index.js +
+
100%44/44100%1/1100%0/0100%44/44
iset.js +
+
97.22%70/7287.5%7/8100%1/197.22%70/72
main.js +
+
100%325/325100%51/51100%1/1100%325/325
set.js +
+
96.25%77/8081.81%9/11100%1/196.25%77/80
validate.js +
+
100%93/93100%21/21100%1/1100%93/93
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/ctor/index.js.html b/ndarray/ctor/index.js.html new file mode 100644 index 000000000..8b4c16c62 --- /dev/null +++ b/ndarray/ctor/index.js.html @@ -0,0 +1,217 @@ + + + + + + Code coverage report for ndarray/ctor/lib/index.js + + + + + + + + + +
+
+

All files / ndarray/ctor/lib index.js

+
+ +
+ 100% + Statements + 44/44 +
+ + +
+ 100% + Branches + 1/1 +
+ + +
+ 100% + Functions + 0/0 +
+ + +
+ 100% + Lines + 44/44 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +4533x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2018 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';
+ 
+/**
+* Multidimensional array constructor.
+*
+* @module @stdlib/ndarray/ctor
+*
+* @example
+* var ndarray = require( '@stdlib/ndarray/ctor' );
+*
+* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
+*/
+ 
+// MODULES //
+ 
+var main = require( './main.js' );
+ 
+ 
+// EXPORTS //
+ 
+module.exports = main;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/ctor/iset.js.html b/ndarray/ctor/iset.js.html new file mode 100644 index 000000000..61d67e44b --- /dev/null +++ b/ndarray/ctor/iset.js.html @@ -0,0 +1,301 @@ + + + + + + Code coverage report for ndarray/ctor/lib/iset.js + + + + + + + + + +
+
+

All files / ndarray/ctor/lib iset.js

+
+ +
+ 97.22% + Statements + 70/72 +
+ + +
+ 87.5% + Branches + 7/8 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 97.22% + Lines + 70/72 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +7333x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +771x +771x +  +  +771x +770x +50x +50x +720x +720x +771x +1x +1x +433x +771x +33x +33x +33x +33x +33x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2018 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 no-invalid-this */
+ 
+'use strict';
+ 
+// METHODS //
+ 
+var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive;
+var getIndex = require( '@stdlib/ndarray/base/ind' );
+var parent = require( '@stdlib/ndarray/base/ctor' ); // eslint-disable-line stdlib/no-redeclare
+var format = require( '@stdlib/string/format' );
+ 
+ 
+// VARIABLES //
+ 
+var base = parent.prototype.iset;
+ 
+ 
+// MAIN //
+ 
+/**
+* Sets an array element located at a specified linear index.
+*
+* ## Notes
+*
+* -   For zero-dimensional arrays, the first, and only, argument should be the value to set.
+*
+* @private
+* @param {integer} [idx] - linear view index
+* @param {*} v - value to set
+* @throws {Error} cannot write to a read-only array
+* @throws {TypeError} index must be an integer
+* @throws {RangeError} index exceeds array dimensions
+* @returns {ndarray} ndarray instance
+*/
+function iset( idx, v ) {
+	if ( this._flags.READONLY ) {
+		throw new Error( 'invalid invocation. Cannot write to a read-only array.' );
+	}
+	if ( this._ndims > 0 ) {
+		if ( !isInteger( idx ) ) {
+			throw new TypeError( format( 'invalid argument. Index must be an integer. Value: `%s`.', idx ) );
+		}
+		idx = getIndex( idx, this._length-1, this._mode );
+		base.call( this, idx, v );
+	} else {
+		base.call( this, idx );
+	}
+	return this;
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = iset;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/ctor/main.js.html b/ndarray/ctor/main.js.html new file mode 100644 index 000000000..926077dc4 --- /dev/null +++ b/ndarray/ctor/main.js.html @@ -0,0 +1,1060 @@ + + + + + + Code coverage report for ndarray/ctor/lib/main.js + + + + + + + + + +
+
+

All files / ndarray/ctor/lib main.js

+
+ +
+ 100% + Statements + 325/325 +
+ + +
+ 100% + Branches + 51/51 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 325/325 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +32633x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +1846x +1846x +1846x +1846x +1846x +1846x +1846x +1846x +920x +427x +427x +493x +493x +1846x +20x +20x +1846x +18x +1846x +4x +4x +1838x +108x +26x +26x +108x +858x +1846x +4x +4x +1846x +60x +60x +1240x +744x +10x +10x +1846x +10x +50x +3x +3x +1846x +22x +22x +1846x +34x +34x +1846x +11x +11x +704x +704x +704x +1383x +391x +391x +19x +19x +391x +685x +899x +603x +603x +685x +685x +685x +685x +1846x +1846x +1846x +1846x +1846x +1846x +1846x +1846x +1846x +1846x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2018 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 no-invalid-this */
+ 
+'use strict';
+ 
+// MODULES //
+ 
+var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
+var isCollection = require( '@stdlib/assert/is-collection' );
+var isNonNegativeIntegerArray = require( '@stdlib/assert/is-nonnegative-integer-array' ).primitives;
+var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive;
+var isIntegerArray = require( '@stdlib/assert/is-integer-array' ).primitives;
+var isFunction = require( '@stdlib/assert/is-function' );
+var isOrder = require( '@stdlib/ndarray/base/assert/is-order' );
+var isDataType = require( '@stdlib/ndarray/base/assert/is-data-type' );
+var isBufferLengthCompatible = require( '@stdlib/ndarray/base/assert/is-buffer-length-compatible' );
+var numel = require( '@stdlib/ndarray/base/numel' );
+var parent = require( '@stdlib/ndarray/base/ctor' ); // eslint-disable-line stdlib/no-redeclare
+var defaults = require( '@stdlib/ndarray/defaults' );
+var inherit = require( '@stdlib/utils/inherit' );
+var format = require( '@stdlib/string/format' );
+var iget = require( './iget.js' );
+var iset = require( './iset.js' );
+var get = require( './get.js' );
+var set = require( './set.js' );
+var copy = require( './copy_array.js' );
+var validate = require( './validate.js' );
+ 
+ 
+// VARIABLES //
+ 
+/*
+* See the following references:
+*
+* -  https://stackoverflow.com/questions/22747068/is-there-a-max-number-of-arguments-javascript-functions-can-accept
+* -  https://bugs.webkit.org/show_bug.cgi?id=80797
+* -  https://github.com/numpy/numpy/issues/5744
+*
+* Note that the maximum number of function arguments can vary from engine to engine. Here, we choose something of a lowest common denominator which may **not** be valid everywhere.
+*/
+var MAX_DIMS = 32767|0;
+ 
+var INDEX_MODE = defaults.get( 'index_mode' );
+var READONLY = false;
+ 
+ 
+// MAIN //
+ 
+/**
+* ndarray constructor.
+*
+* @constructor
+* @param {string} dtype - data type
+* @param {Collection} buffer - data buffer
+* @param {NonNegativeIntegerArray} shape - array shape
+* @param {IntegerArray} strides - array strides
+* @param {NonNegativeInteger} offset - index offset
+* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)
+* @param {Options} [options] - function options
+* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions
+* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
+* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only
+* @throws {TypeError} `dtype` argument must be a supported ndarray data type
+* @throws {TypeError} `buffer` argument must be an array-like object, typed-array-like, or a Buffer
+* @throws {TypeError} `buffer` argument `get` and `set` properties must be functions
+* @throws {TypeError} `shape` argument must be an array-like object containing nonnegative integers
+* @throws {Error} `shape` argument length must equal the number of dimensions
+* @throws {TypeError} `strides` argument must be an array-like object containing integers
+* @throws {Error} `strides` argument length must equal the number of dimensions (except for zero-dimensional arrays; in which case, the `strides` argument length must be equal to `1`)
+* @throws {Error} for zero-dimensional ndarrays, the `strides` argument must contain a single element equal to `0`
+* @throws {TypeError} `offset` argument must be a nonnegative integer
+* @throws {TypeError} `order` argument must be a supported ndarray order
+* @throws {Error} `buffer` argument must be compatible with specified meta data
+* @throws {TypeError} options argument must be an object
+* @throws {TypeError} must provide valid options
+* @throws {RangeError} too many dimensions
+* @returns {ndarray} ndarray instance
+*
+* @example
+* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
+*/
+function ndarray( dtype, buffer, shape, strides, offset, order, options ) {
+	var ndims;
+	var opts;
+	var err;
+	var sh;
+	var st;
+ 
+	if ( !(this instanceof ndarray) ) {
+		if ( arguments.length < 7 ) {
+			return new ndarray( dtype, buffer, shape, strides, offset, order );
+		}
+		return new ndarray( dtype, buffer, shape, strides, offset, order, options ); // eslint-disable-line max-len
+	}
+	if ( !isDataType( dtype ) ) {
+		throw new TypeError( format( 'invalid argument. First argument must be a supported ndarray data type. Value: `%s`.', dtype ) );
+	}
+	if ( !isCollection( buffer ) ) {
+		throw new TypeError( format( 'invalid argument. Second argument must be an array-like object, typed-array-like, or a Buffer. Value: `%s`.', buffer ) );
+	} else if ( buffer.get && buffer.set && ( !isFunction( buffer.get ) || !isFunction( buffer.set ) ) ) { // eslint-disable-line max-len
+		throw new TypeError( format( 'invalid argument. Second argument `get` and `set` properties must be functions. Value: `%s`.', buffer ) );
+	}
+	if ( !isNonNegativeIntegerArray( shape ) ) {
+		if ( !isCollection( shape) || shape.length > 0 ) {
+			throw new TypeError( format( 'invalid argument. Third argument must be an array-like object containing nonnegative integers. Value: `%s`.', shape ) );
+		}
+	}
+	ndims = shape.length;
+	if ( ndims > MAX_DIMS ) {
+		throw new RangeError( format( 'invalid argument. Number of dimensions must not exceed %u due to stack limits. Value: `%u`.', MAX_DIMS, ndims ) );
+	}
+	if ( !isIntegerArray( strides ) ) {
+		throw new TypeError( format( 'invalid argument. Fourth argument must be an array-like object containing integers. Value: `%s`.', strides ) );
+	}
+	if ( ndims > 0 ) {
+		if ( strides.length !== ndims ) {
+			throw new RangeError( format( 'invalid argument. Fourth argument length must match the number of dimensions. Expected number of dimensions: `%u`. Strides length: `%u`.', ndims, strides.length ) );
+		}
+	} else if ( strides.length !== 1 ) {
+		throw new RangeError( 'invalid argument. Fourth argument length must be equal to 1 when creating a zero-dimensional ndarray.' );
+	} else if ( strides[ 0 ] !== 0 ) {
+		throw new RangeError( format( 'invalid argument. Fourth argument must contain a single element equal to 0. Value: `%d`.', strides[ 0 ] ) );
+	}
+	if ( !isNonNegativeInteger( offset ) ) {
+		throw new TypeError( format( 'invalid argument. Fifth argument must be a nonnegative integer. Value: `%s`.', offset ) );
+	}
+	if ( !isOrder( order ) ) {
+		throw new TypeError( format( 'invalid argument. Sixth argument must be a supported order. Value: `%s`.', order ) );
+	}
+	if ( ndims > 0 && !isBufferLengthCompatible( buffer.length, shape, strides, offset ) && numel( shape ) > 0 ) { // eslint-disable-line max-len
+		throw new Error( 'invalid arguments. Input buffer is incompatible with the specified meta data. Ensure that the offset is valid with regard to the strides array and that the buffer has enough elements to satisfy the desired array shape.' );
+	}
+	opts = {};
+	opts.mode = INDEX_MODE;
+	opts.readonly = READONLY;
+	if ( arguments.length > 6 ) {
+		err = validate( opts, options );
+		if ( err ) {
+			throw err;
+		}
+	}
+	this._mode = opts.mode;
+	if ( opts.submode === void 0 ) {
+		opts.submode = [ this._mode ];
+	}
+	this._submode = opts.submode;
+ 
+	// Copy `shape` and `strides` to prevent external mutation:
+	sh = copy( shape, ndims );
+	st = copy( strides, ndims || 1 );
+ 
+	// Call the parent constructor:
+	parent.call( this, dtype, buffer, sh, st, offset, order );
+	this._flags.READONLY = opts.readonly;
+ 
+	return this;
+ 
+	/* eslint-enable no-invalid-this */
+}
+ 
+// Inherit from the parent constructor:
+inherit( ndarray, parent );
+ 
+/**
+* Constructor name.
+*
+* @name name
+* @memberof ndarray
+* @type {string}
+* @default 'ndarray'
+*
+* @example
+* var str = ndarray.name;
+* // returns 'ndarray'
+*/
+setReadOnly( ndarray, 'name', 'ndarray' );
+ 
+/**
+* Returns an array element.
+*
+* ## Notes
+*
+* -   The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.
+*
+* @name get
+* @memberof ndarray.prototype
+* @type {Function}
+* @param {...integer} [idx] - indices
+* @returns {*} array element
+*
+* @example
+* var buffer = [ 1, 2, 3, 4, 5, 6 ];
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
+*
+* var v = x.get( 1, 1 );
+* // returns 4
+*/
+setReadOnly( ndarray.prototype, 'get', get );
+ 
+/**
+* Returns an array element located at a specified linear index.
+*
+* ## Notes
+*
+* -   For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.
+*
+* @name iget
+* @memberof ndarray.prototype
+* @type {Function}
+* @param {integer} [idx] - linear index
+* @returns {*} array element
+*
+* @example
+* var buffer = [ 1, 2, 3, 4, 5, 6 ];
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
+*
+* var v = x.iget( 3 );
+* // returns 4
+*/
+setReadOnly( ndarray.prototype, 'iget', iget );
+ 
+/**
+* Sets an array element.
+*
+* ## Notes
+*
+* -   The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.
+*
+* @name set
+* @memberof ndarray.prototype
+* @type {Function}
+* @param {...integer} [idx] - indices
+* @param {*} v - value to set
+* @returns {ndarray} ndarray instance
+*
+* @example
+* var buffer = [ 1, 2, 3, 4, 5, 6 ];
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
+*
+* var v = x.get( 1, 1 );
+* // returns 4
+*
+* x.set( 1, 1, 10 );
+*
+* var b = x.data;
+* // returns [ 1, 2, 3, 10, 5, 6 ]
+*
+* v = x.get( 1, 1 );
+* // returns 10
+*/
+setReadOnly( ndarray.prototype, 'set', set );
+ 
+/**
+* Sets an array element located at a specified linear index.
+*
+* ## Notes
+*
+* -   For zero-dimensional arrays, the first, and only, argument should be the value to set.
+*
+* @name iset
+* @memberof ndarray.prototype
+* @type {Function}
+* @param {integer} [idx] - linear index
+* @param {*} v - value to set
+* @returns {ndarray} ndarray instance
+*
+* @example
+* var buffer = [ 1, 2, 3, 4, 5, 6 ];
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
+*
+* var v = x.iget( 3 );
+* // returns 4
+*
+* x.iset( 3, 10 );
+*
+* var b = x.data;
+* // returns [ 1, 2, 3, 10, 5, 6 ]
+*
+* v = x.iget( 3 );
+* // returns 10
+*/
+setReadOnly( ndarray.prototype, 'iset', iset );
+ 
+ 
+// EXPORTS //
+ 
+module.exports = ndarray;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/ctor/set.js.html b/ndarray/ctor/set.js.html new file mode 100644 index 000000000..843e03b41 --- /dev/null +++ b/ndarray/ctor/set.js.html @@ -0,0 +1,325 @@ + + + + + + Code coverage report for ndarray/ctor/lib/set.js + + + + + + + + + +
+
+

All files / ndarray/ctor/lib set.js

+
+ +
+ 96.25% + Statements + 77/80 +
+ + +
+ 81.81% + Branches + 9/11 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 96.25% + Lines + 77/80 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +8133x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +33x +546x +546x +546x +546x +546x +546x +546x +  +  +546x +11x +11x +535x +535x +546x +1358x +150x +150x +1208x +1208x +1208x +546x +  +546x +265x +265x +265x +546x +33x +33x +33x +33x +33x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2018 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 no-invalid-this */
+ 
+'use strict';
+ 
+// MODULES //
+ 
+var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive;
+var getIndex = require( '@stdlib/ndarray/base/ind' );
+var format = require( '@stdlib/string/format' );
+ 
+ 
+// MAIN //
+ 
+/**
+* Sets an array element.
+*
+* ## Notes
+*
+* -   The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.
+*
+* @private
+* @param {...integer} [idx] - indices
+* @param {*} v - value to set
+* @throws {Error} cannot write to a read-only array
+* @throws {TypeError} provided indices must be integer valued
+* @throws {RangeError} index exceeds array dimensions
+* @throws {RangeError} number of indices must equal the number of dimensions
+* @returns {ndarray} ndarray instance
+*/
+function set() {
+	var idx;
+	var ind;
+	var M;
+	var i;
+ 
+	if ( this._flags.READONLY ) {
+		throw new Error( 'invalid invocation. Cannot write to a read-only array.' );
+	}
+	if ( arguments.length !== this._ndims+1 ) {
+		throw new RangeError( format( 'invalid arguments. Number of indices must match the number of dimensions. ndims: `%u`. nargs: `%u`.', this._ndims, arguments.length ) );
+	}
+	idx = this._offset;
+	M = this._submode.length;
+	for ( i = 0; i < arguments.length-1; i++ ) {
+		if ( !isInteger( arguments[ i ] ) ) {
+			throw new TypeError( format( 'invalid argument. Indices must be integer valued. Argument: `%i`. Value: `%s`.', i, arguments[ i ] ) );
+		}
+		ind = getIndex( arguments[ i ], this._shape[ i ]-1, this._submode[ i%M ] ); // eslint-disable-line max-len
+		idx += this._strides[ i ] * ind;
+	}
+	if ( this._accessors ) {
+		this._buffer.set( arguments[ i ], idx );
+	} else {
+		this._buffer[ idx ] = arguments[ i ];
+	}
+	return this;
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = set;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/ctor/validate.js.html b/ndarray/ctor/validate.js.html new file mode 100644 index 000000000..4d508b71d --- /dev/null +++ b/ndarray/ctor/validate.js.html @@ -0,0 +1,364 @@ + + + + + + Code coverage report for ndarray/ctor/lib/validate.js + + + + + + + + + +
+
+

All files / ndarray/ctor/lib validate.js

+
+ +
+ 100% + Statements + 93/93 +
+ + +
+ 100% + Branches + 21/21 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 93/93 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +9434x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +34x +453x +453x +453x +18x +18x +444x +339x +339x +31x +31x +339x +434x +105x +105x +20x +20x +105x +1x +1x +105x +174x +1x +1x +174x +83x +83x +434x +9x +9x +8x +8x +9x +374x +453x +34x +34x +34x +34x +34x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2018 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 isObject = require( '@stdlib/assert/is-plain-object' );
+var hasOwnProp = require( '@stdlib/assert/has-own-property' );
+var isArray = require( '@stdlib/assert/is-array' );
+var isIndexMode = require( '@stdlib/ndarray/base/assert/is-index-mode' );
+var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
+var format = require( '@stdlib/string/format' );
+ 
+ 
+// MAIN //
+ 
+/**
+* Validates function options.
+*
+* @private
+* @param {Object} opts - destination object
+* @param {Options} options - function options
+* @param {string} [options.mode] - specifies how to handle indices which exceed array dimensions
+* @param {string} [options.submode] - specifies how to handle subscripts which exceed array dimensions
+* @param {boolean} [options.readonly] - boolean indicating whether an array should be read-only
+* @returns {(Error|null)} null or an error object
+*
+* @example
+* var opts = {};
+* var options = {
+*     'mode': 'clamp',
+*     'submode': [ 'throw', 'wrap', 'clamp' ]
+* };
+* var err = validate( opts, options );
+* if ( err ) {
+*     throw err;
+* }
+*/
+function validate( opts, options ) {
+	var i;
+	if ( !isObject( options ) ) {
+		return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
+	}
+	if ( hasOwnProp( options, 'mode' ) ) {
+		opts.mode = options.mode;
+		if ( !isIndexMode( opts.mode ) ) {
+			return new TypeError( format( 'invalid option. `%s` option must be a recognized mode. Option: `%s`.', 'mode', opts.mode ) );
+		}
+	}
+	if ( hasOwnProp( options, 'submode' ) ) {
+		opts.submode = options.submode;
+		if ( !isArray( opts.submode ) ) {
+			return new TypeError( format( 'invalid option. `%s` option must be an array containing recognized modes. Option: `%s`.', 'submode', opts.submode ) );
+		}
+		if ( opts.submode.length === 0 ) {
+			return new TypeError( format( 'invalid option. `%s` option must be an array containing recognized modes. Option: `%s`.', 'submode', opts.submode.join( ',' ) ) );
+		}
+		for ( i = 0; i < opts.submode.length; i++ ) {
+			if ( !isIndexMode( opts.submode[ i ] ) ) {
+				return new TypeError( format( 'invalid option. Each submode must be a recognized mode. Option: `%s`.', opts.submode[ i ] ) );
+			}
+		}
+		opts.submode = opts.submode.slice();
+	}
+	if ( hasOwnProp( options, 'readonly' ) ) {
+		opts.readonly = options.readonly;
+		if ( !isBoolean( opts.readonly ) ) {
+			return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readonly', opts.readonly ) );
+		}
+	}
+	return null;
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = validate;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/fancy/array_options.js.html b/ndarray/fancy/array_options.js.html index 93d3c345f..e0817f1f8 100644 --- a/ndarray/fancy/array_options.js.html +++ b/ndarray/fancy/array_options.js.html @@ -187,7 +187,7 @@

All files / ndarray/f