diff --git a/namespace/alias2pkg/coverage.ndjson b/namespace/alias2pkg/coverage.ndjson index 1d5708a67..fa0dd731a 100644 --- a/namespace/alias2pkg/coverage.ndjson +++ b/namespace/alias2pkg/coverage.ndjson @@ -10,3 +10,4 @@ [95,95,100,7,7,100,1,1,100,95,95,100,"34b1f69b901244fb6031b62807c15f2b57aad033","2023-10-05 17:59:18 -0700"] [95,95,100,7,7,100,1,1,100,95,95,100,"c8af478451bc77398bada48450f65406ba460504","2023-10-06 12:45:00 -0700"] [95,95,100,7,7,100,1,1,100,95,95,100,"7ac268b4abd82075b329f16ba991d0d36524fe12","2023-10-06 15:58:23 -0700"] +[95,95,100,7,7,100,1,1,100,95,95,100,"6b48944663c08f64956469340e8561704d9923f8","2023-10-06 16:41:23 -0700"] diff --git a/namespace/alias2pkg/index.html b/namespace/alias2pkg/index.html index 1faf61e84..b65abb058 100644 --- a/namespace/alias2pkg/index.html +++ b/namespace/alias2pkg/index.html @@ -116,7 +116,7 @@

All files namespace/alias2pkg/lib

+ + + + + + \ No newline at end of file diff --git a/ndarray/base/ndims/index.js.html b/ndarray/base/ndims/index.js.html new file mode 100644 index 000000000..1d4349734 --- /dev/null +++ b/ndarray/base/ndims/index.js.html @@ -0,0 +1,208 @@ + + + + + + Code coverage report for ndarray/base/ndims/lib/index.js + + + + + + + + + +
+
+

All files / ndarray/base/ndims/lib index.js

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

+ 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 +421x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 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 the number of ndarray dimensions.
+*
+* @module @stdlib/ndarray/base/ndims
+*
+* @example
+* var zeros = require( '@stdlib/ndarray/zeros' );
+* var ndims = require( '@stdlib/ndarray/base/ndims' );
+*
+* var n = ndims( zeros( [ 3, 3, 3 ] ) );
+* // returns 3
+*/
+ 
+// MODULES //
+ 
+var main = require( './main.js' );
+ 
+ 
+// EXPORTS //
+ 
+module.exports = main;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/base/ndims/main.js.html b/ndarray/base/ndims/main.js.html new file mode 100644 index 000000000..b3560431a --- /dev/null +++ b/ndarray/base/ndims/main.js.html @@ -0,0 +1,223 @@ + + + + + + Code coverage report for ndarray/base/ndims/lib/main.js + + + + + + + + + +
+
+

All files / ndarray/base/ndims/lib main.js

+
+ +
+ 100% + Statements + 46/46 +
+ + +
+ 100% + Branches + 4/4 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 46/46 +
+ + +
+

+ 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 +471x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +16x +16x +16x +11x +11x +5x +16x +1x +1x +1x +1x +1x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 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 //
+ 
+/**
+* Returns the number of ndarray dimensions.
+*
+* @param {ndarrayLike} x - input ndarray
+* @returns {NonNegativeInteger} number of dimensions
+*
+* @example
+* var zeros = require( '@stdlib/ndarray/zeros' );
+*
+* var n = ndims( zeros( [ 3, 3, 3 ] ) );
+* // returns 3
+*/
+function ndims( x ) {
+	var n = x.ndims; // Note: intentionally cache in case `ndims` is lazily resolved via accessor
+	if ( typeof n === 'number' ) {
+		return n;
+	}
+	return x.shape.length;
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = ndims;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/coverage.ndjson b/ndarray/coverage.ndjson index ad5bbbb7d..18d8097b3 100644 --- a/ndarray/coverage.ndjson +++ b/ndarray/coverage.ndjson @@ -5,3 +5,4 @@ [294,294,100,1,1,100,0,0,100,294,294,100,"836b37cf688bfa381fcb3cb3a2dd327f0a94ad19","2023-10-01 21:09:27 -0700"] [303,303,100,1,1,100,0,0,100,303,303,100,"c8af478451bc77398bada48450f65406ba460504","2023-10-06 12:45:00 -0700"] [312,312,100,1,1,100,0,0,100,312,312,100,"7ac268b4abd82075b329f16ba991d0d36524fe12","2023-10-06 15:58:23 -0700"] +[321,321,100,1,1,100,0,0,100,321,321,100,"6b48944663c08f64956469340e8561704d9923f8","2023-10-06 16:41:23 -0700"] diff --git a/ndarray/index.html b/ndarray/index.html index 2866aa3b2..9975e4944 100644 --- a/ndarray/index.html +++ b/ndarray/index.html @@ -25,7 +25,7 @@

All files ndarray/lib

100% Statements - 312/312 + 321/321
@@ -46,7 +46,7 @@

All files ndarray/lib

100% Lines - 312/312 + 321/321
@@ -84,13 +84,13 @@

All files ndarray/lib

100% - 312/312 + 321/321 100% 1/1 100% 0/0 100% - 312/312 + 321/321 @@ -101,7 +101,7 @@

All files ndarray/lib

+ + + + + + \ No newline at end of file diff --git a/ndarray/ndims/index.js.html b/ndarray/ndims/index.js.html new file mode 100644 index 000000000..255b0f617 --- /dev/null +++ b/ndarray/ndims/index.js.html @@ -0,0 +1,208 @@ + + + + + + Code coverage report for ndarray/ndims/lib/index.js + + + + + + + + + +
+
+

All files / ndarray/ndims/lib index.js

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

+ 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 +421x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 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 the number of ndarray dimensions.
+*
+* @module @stdlib/ndarray/ndims
+*
+* @example
+* var zeros = require( '@stdlib/ndarray/zeros' );
+* var ndims = require( '@stdlib/ndarray/ndims' );
+*
+* var n = ndims( zeros( [ 3, 3, 3 ] ) );
+* // returns 3
+*/
+ 
+// MODULES //
+ 
+var main = require( './main.js' );
+ 
+ 
+// EXPORTS //
+ 
+module.exports = main;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/ndims/main.js.html b/ndarray/ndims/main.js.html new file mode 100644 index 000000000..6a91861fe --- /dev/null +++ b/ndarray/ndims/main.js.html @@ -0,0 +1,280 @@ + + + + + + Code coverage report for ndarray/ndims/lib/main.js + + + + + + + + + +
+
+

All files / ndarray/ndims/lib main.js

+
+ +
+ 100% + Statements + 65/65 +
+ + +
+ 100% + Branches + 8/8 +
+ + +
+ 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 +661x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +29x +29x +29x +29x +29x +29x +8x +8x +21x +29x +11x +11x +10x +29x +5x +5x +5x +29x +1x +1x +1x +1x +1x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 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 isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive;
+var isCollection = require( '@stdlib/assert/is-collection' );
+var format = require( '@stdlib/string/format' );
+ 
+ 
+// MAIN //
+ 
+/**
+* Returns the number of ndarray dimensions.
+*
+* @param {ndarrayLike} x - input ndarray
+* @throws {TypeError} must provide an ndarray
+* @returns {NonNegativeInteger} number of dimensions
+*
+* @example
+* var zeros = require( '@stdlib/ndarray/zeros' );
+*
+* var n = ndims( zeros( [ 3, 3, 3 ] ) );
+* // returns 3
+*/
+function ndims( x ) {
+	var sh;
+	var n;
+ 
+	// Note: we intentionally avoid rigorous ndarray checks to minimize performance impacts. This obviously means that non-ndarray-like objects can sneak through, but this is likely all right for the purposes of this function...
+	if ( typeof x !== 'object' || x === null ) {
+		throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );
+	}
+	n = x.ndims;
+	if ( isNonNegativeInteger( n ) ) {
+		return n;
+	}
+	sh = x.shape;
+	if ( !isCollection( sh ) ) {
+		throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );
+	}
+	return sh.length;
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = ndims;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/repl/code-blocks/coverage.ndjson b/repl/code-blocks/coverage.ndjson index 5f987f335..c9c2bca48 100644 --- a/repl/code-blocks/coverage.ndjson +++ b/repl/code-blocks/coverage.ndjson @@ -11,3 +11,4 @@ [95,95,100,7,7,100,1,1,100,95,95,100,"34b1f69b901244fb6031b62807c15f2b57aad033","2023-10-05 17:59:18 -0700"] [95,95,100,7,7,100,1,1,100,95,95,100,"c8af478451bc77398bada48450f65406ba460504","2023-10-06 12:45:00 -0700"] [95,95,100,7,7,100,1,1,100,95,95,100,"7ac268b4abd82075b329f16ba991d0d36524fe12","2023-10-06 15:58:23 -0700"] +[95,95,100,7,7,100,1,1,100,95,95,100,"6b48944663c08f64956469340e8561704d9923f8","2023-10-06 16:41:23 -0700"] diff --git a/repl/code-blocks/index.html b/repl/code-blocks/index.html index 1b7e28b0e..98026f438 100644 --- a/repl/code-blocks/index.html +++ b/repl/code-blocks/index.html @@ -116,7 +116,7 @@

All files repl/code-blocks/lib