diff --git a/ndarray/base/coverage.ndjson b/ndarray/base/coverage.ndjson new file mode 100644 index 000000000..901a0ac5e --- /dev/null +++ b/ndarray/base/coverage.ndjson @@ -0,0 +1 @@ +[631,631,100,1,1,100,0,0,100,631,631,100,"fcbe4c18fd4ebfad0466b56b4c19abda6cdb4c2b","2023-09-26 14:05:25 -0700"] diff --git a/ndarray/base/index.html b/ndarray/base/index.html new file mode 100644 index 000000000..01cd1743d --- /dev/null +++ b/ndarray/base/index.html @@ -0,0 +1,116 @@ + + + + + + Code coverage report for ndarray/base/lib + + + + + + + + + +
+
+

All files ndarray/base/lib

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

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

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
index.js +
+
100%631/631100%1/1100%0/0100%631/631
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/base/index.js.html b/ndarray/base/index.js.html new file mode 100644 index 000000000..e5df9e1b0 --- /dev/null +++ b/ndarray/base/index.js.html @@ -0,0 +1,1978 @@ + + + + + + Code coverage report for ndarray/base/lib/index.js + + + + + + + + + +
+
+

All files / ndarray/base/lib index.js

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

+ 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 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +6321x +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + 
/**
+* @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';
+ 
+/*
+* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
+*/
+ 
+/*
+* The following modules are intentionally not exported: function-object, napi, unary
+*/
+ 
+// MODULES //
+ 
+var setReadOnly = require( '@stdlib/utils/define-read-only-property' );
+ 
+ 
+// MAIN //
+ 
+/**
+* Top-level namespace.
+*
+* @namespace ns
+*/
+var ns = {};
+ 
+/**
+* @name assert
+* @memberof ns
+* @readonly
+* @type {Namespace}
+* @see {@link module:@stdlib/ndarray/base/assert}
+*/
+setReadOnly( ns, 'assert', require( '@stdlib/ndarray/base/assert' ) );
+ 
+/**
+* @name binaryLoopOrder
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/binary-loop-interchange-order}
+*/
+setReadOnly( ns, 'binaryLoopOrder', require( '@stdlib/ndarray/base/binary-loop-interchange-order' ) );
+ 
+/**
+* @name binaryBlockSize
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/binary-tiling-block-size}
+*/
+setReadOnly( ns, 'binaryBlockSize', require( '@stdlib/ndarray/base/binary-tiling-block-size' ) );
+ 
+/**
+* @name bind2vind
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/bind2vind}
+*/
+setReadOnly( ns, 'bind2vind', require( '@stdlib/ndarray/base/bind2vind' ) );
+ 
+/**
+* @name broadcastArray
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/broadcast-array}
+*/
+setReadOnly( ns, 'broadcastArray', require( '@stdlib/ndarray/base/broadcast-array' ) );
+ 
+/**
+* @name broadcastScalar
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/broadcast-scalar}
+*/
+setReadOnly( ns, 'broadcastScalar', require( '@stdlib/ndarray/base/broadcast-scalar' ) );
+ 
+/**
+* @name broadcastShapes
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/broadcast-shapes}
+*/
+setReadOnly( ns, 'broadcastShapes', require( '@stdlib/ndarray/base/broadcast-shapes' ) );
+ 
+/**
+* @name buffer
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/buffer}
+*/
+setReadOnly( ns, 'buffer', require( '@stdlib/ndarray/base/buffer' ) );
+ 
+/**
+* @name bufferCtors
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/buffer-ctors}
+*/
+setReadOnly( ns, 'bufferCtors', require( '@stdlib/ndarray/base/buffer-ctors' ) );
+ 
+/**
+* @name bufferDataType
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/buffer-dtype}
+*/
+setReadOnly( ns, 'bufferDataType', require( '@stdlib/ndarray/base/buffer-dtype' ) );
+ 
+/**
+* @name bufferDataTypeEnum
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/buffer-dtype-enum}
+*/
+setReadOnly( ns, 'bufferDataTypeEnum', require( '@stdlib/ndarray/base/buffer-dtype-enum' ) );
+ 
+/**
+* @name bytesPerElement
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/bytes-per-element}
+*/
+setReadOnly( ns, 'bytesPerElement', require( '@stdlib/ndarray/base/bytes-per-element' ) );
+ 
+/**
+* @name char2dtype
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/char2dtype}
+*/
+setReadOnly( ns, 'char2dtype', require( '@stdlib/ndarray/base/char2dtype' ) );
+ 
+/**
+* @name clampIndex
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/clamp-index}
+*/
+setReadOnly( ns, 'clampIndex', require( '@stdlib/ndarray/base/clamp-index' ) );
+ 
+/**
+* @name ndarray
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/ctor}
+*/
+setReadOnly( ns, 'ndarray', require( '@stdlib/ndarray/base/ctor' ) );
+ 
+/**
+* @name dtypeChar
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/dtype-char}
+*/
+setReadOnly( ns, 'dtypeChar', require( '@stdlib/ndarray/base/dtype-char' ) );
+ 
+/**
+* @name dtypeDesc
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/dtype-desc}
+*/
+setReadOnly( ns, 'dtypeDesc', require( '@stdlib/ndarray/base/dtype-desc' ) );
+ 
+/**
+* @name dtypeEnum2Str
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/dtype-enum2str}
+*/
+setReadOnly( ns, 'dtypeEnum2Str', require( '@stdlib/ndarray/base/dtype-enum2str' ) );
+ 
+/**
+* @name dtypeResolveEnum
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/dtype-resolve-enum}
+*/
+setReadOnly( ns, 'dtypeResolveEnum', require( '@stdlib/ndarray/base/dtype-resolve-enum' ) );
+ 
+/**
+* @name dtypeResolveStr
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/dtype-resolve-str}
+*/
+setReadOnly( ns, 'dtypeResolveStr', require( '@stdlib/ndarray/base/dtype-resolve-str' ) );
+ 
+/**
+* @name dtypeStr2Enum
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/dtype-str2enum}
+*/
+setReadOnly( ns, 'dtypeStr2Enum', require( '@stdlib/ndarray/base/dtype-str2enum' ) );
+ 
+/**
+* @name dtype2c
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/dtype2c}
+*/
+setReadOnly( ns, 'dtype2c', require( '@stdlib/ndarray/base/dtype2c' ) );
+ 
+/**
+* @name dtypes2signatures
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/dtypes2signatures}
+*/
+setReadOnly( ns, 'dtypes2signatures', require( '@stdlib/ndarray/base/dtypes2signatures' ) );
+ 
+/**
+* @name empty
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/empty}
+*/
+setReadOnly( ns, 'empty', require( '@stdlib/ndarray/base/empty' ) );
+ 
+/**
+* @name emptyLike
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/empty-like}
+*/
+setReadOnly( ns, 'emptyLike', require( '@stdlib/ndarray/base/empty-like' ) );
+ 
+/**
+* @name expandDimensions
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/expand-dimensions}
+*/
+setReadOnly( ns, 'expandDimensions', require( '@stdlib/ndarray/base/expand-dimensions' ) );
+ 
+/**
+* @name scalar2ndarray
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/from-scalar}
+*/
+setReadOnly( ns, 'scalar2ndarray', require( '@stdlib/ndarray/base/from-scalar' ) );
+ 
+/**
+* @name ind
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/ind}
+*/
+setReadOnly( ns, 'ind', require( '@stdlib/ndarray/base/ind' ) );
+ 
+/**
+* @name ind2sub
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/ind2sub}
+*/
+setReadOnly( ns, 'ind2sub', require( '@stdlib/ndarray/base/ind2sub' ) );
+ 
+/**
+* @name iterationOrder
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/iteration-order}
+*/
+setReadOnly( ns, 'iterationOrder', require( '@stdlib/ndarray/base/iteration-order' ) );
+ 
+/**
+* @name maxViewBufferIndex
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/max-view-buffer-index}
+*/
+setReadOnly( ns, 'maxViewBufferIndex', require( '@stdlib/ndarray/base/max-view-buffer-index' ) );
+ 
+/**
+* @name maybeBroadcastArray
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/maybe-broadcast-array}
+*/
+setReadOnly( ns, 'maybeBroadcastArray', require( '@stdlib/ndarray/base/maybe-broadcast-array' ) );
+ 
+/**
+* @name metaDataProps
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/meta-data-props}
+*/
+setReadOnly( ns, 'metaDataProps', require( '@stdlib/ndarray/base/meta-data-props' ) );
+ 
+/**
+* @name minViewBufferIndex
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/min-view-buffer-index}
+*/
+setReadOnly( ns, 'minViewBufferIndex', require( '@stdlib/ndarray/base/min-view-buffer-index' ) );
+ 
+/**
+* @name minmaxViewBufferIndex
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/minmax-view-buffer-index}
+*/
+setReadOnly( ns, 'minmaxViewBufferIndex', require( '@stdlib/ndarray/base/minmax-view-buffer-index' ) );
+ 
+/**
+* @name ndarraylike2object
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/ndarraylike2object}
+*/
+setReadOnly( ns, 'ndarraylike2object', require( '@stdlib/ndarray/base/ndarraylike2object' ) );
+ 
+/**
+* @name nonsingletonDimensions
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/nonsingleton-dimensions}
+*/
+setReadOnly( ns, 'nonsingletonDimensions', require( '@stdlib/ndarray/base/nonsingleton-dimensions' ) );
+ 
+/**
+* @name nullary
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/nullary}
+*/
+setReadOnly( ns, 'nullary', require( '@stdlib/ndarray/base/nullary' ) );
+ 
+/**
+* @name nullaryLoopOrder
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/nullary-loop-interchange-order}
+*/
+setReadOnly( ns, 'nullaryLoopOrder', require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ) );
+ 
+/**
+* @name nullaryBlockSize
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/nullary-tiling-block-size}
+*/
+setReadOnly( ns, 'nullaryBlockSize', require( '@stdlib/ndarray/base/nullary-tiling-block-size' ) );
+ 
+/**
+* @name numel
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/numel}
+*/
+setReadOnly( ns, 'numel', require( '@stdlib/ndarray/base/numel' ) );
+ 
+/**
+* @name outputPolicyEnum2Str
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/output-policy-enum2str}
+*/
+setReadOnly( ns, 'outputPolicyEnum2Str', require( '@stdlib/ndarray/base/output-policy-enum2str' ) );
+ 
+/**
+* @name outputPolicyResolveEnum
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/output-policy-resolve-enum}
+*/
+setReadOnly( ns, 'outputPolicyResolveEnum', require( '@stdlib/ndarray/base/output-policy-resolve-enum' ) );
+ 
+/**
+* @name outputPolicyResolveStr
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/output-policy-resolve-str}
+*/
+setReadOnly( ns, 'outputPolicyResolveStr', require( '@stdlib/ndarray/base/output-policy-resolve-str' ) );
+ 
+/**
+* @name outputPolicyStr2Enum
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/output-policy-str2enum}
+*/
+setReadOnly( ns, 'outputPolicyStr2Enum', require( '@stdlib/ndarray/base/output-policy-str2enum' ) );
+ 
+/**
+* @name prependSingletonDimensions
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/prepend-singleton-dimensions}
+*/
+setReadOnly( ns, 'prependSingletonDimensions', require( '@stdlib/ndarray/base/prepend-singleton-dimensions' ) );
+ 
+/**
+* @name removeSingletonDimensions
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/remove-singleton-dimensions}
+*/
+setReadOnly( ns, 'removeSingletonDimensions', require( '@stdlib/ndarray/base/remove-singleton-dimensions' ) );
+ 
+/**
+* @name serializeMetaData
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/serialize-meta-data}
+*/
+setReadOnly( ns, 'serializeMetaData', require( '@stdlib/ndarray/base/serialize-meta-data' ) );
+ 
+/**
+* @name shape2strides
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/shape2strides}
+*/
+setReadOnly( ns, 'shape2strides', require( '@stdlib/ndarray/base/shape2strides' ) );
+ 
+/**
+* @name singletonDimensions
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/singleton-dimensions}
+*/
+setReadOnly( ns, 'singletonDimensions', require( '@stdlib/ndarray/base/singleton-dimensions' ) );
+ 
+/**
+* @name slice
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/slice}
+*/
+setReadOnly( ns, 'slice', require( '@stdlib/ndarray/base/slice' ) );
+ 
+/**
+* @name strides2offset
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/strides2offset}
+*/
+setReadOnly( ns, 'strides2offset', require( '@stdlib/ndarray/base/strides2offset' ) );
+ 
+/**
+* @name strides2order
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/strides2order}
+*/
+setReadOnly( ns, 'strides2order', require( '@stdlib/ndarray/base/strides2order' ) );
+ 
+/**
+* @name sub2ind
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/sub2ind}
+*/
+setReadOnly( ns, 'sub2ind', require( '@stdlib/ndarray/base/sub2ind' ) );
+ 
+/**
+* @name ndarray2array
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/to-array}
+*/
+setReadOnly( ns, 'ndarray2array', require( '@stdlib/ndarray/base/to-array' ) );
+ 
+/**
+* @name transpose
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/transpose}
+*/
+setReadOnly( ns, 'transpose', require( '@stdlib/ndarray/base/transpose' ) );
+ 
+/**
+* @name unary
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/unary}
+*/
+setReadOnly( ns, 'unary', require( '@stdlib/ndarray/base/unary' ) );
+ 
+/**
+* @name unaryBy
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/unary-by}
+*/
+setReadOnly( ns, 'unaryBy', require( '@stdlib/ndarray/base/unary-by' ) );
+ 
+/**
+* @name unaryLoopOrder
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/unary-loop-interchange-order}
+*/
+setReadOnly( ns, 'unaryLoopOrder', require( '@stdlib/ndarray/base/unary-loop-interchange-order' ) );
+ 
+/**
+* @name unaryOutputDataType
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/unary-output-dtype}
+*/
+setReadOnly( ns, 'unaryOutputDataType', require( '@stdlib/ndarray/base/unary-output-dtype' ) );
+ 
+/**
+* @name unaryBlockSize
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/unary-tiling-block-size}
+*/
+setReadOnly( ns, 'unaryBlockSize', require( '@stdlib/ndarray/base/unary-tiling-block-size' ) );
+ 
+/**
+* @name vind2bind
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/vind2bind}
+*/
+setReadOnly( ns, 'vind2bind', require( '@stdlib/ndarray/base/vind2bind' ) );
+ 
+/**
+* @name wrapIndex
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/wrap-index}
+*/
+setReadOnly( ns, 'wrapIndex', require( '@stdlib/ndarray/base/wrap-index' ) );
+ 
+/**
+* @name zeros
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/zeros}
+*/
+setReadOnly( ns, 'zeros', require( '@stdlib/ndarray/base/zeros' ) );
+ 
+/**
+* @name zerosLike
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/zeros-like}
+*/
+setReadOnly( ns, 'zerosLike', require( '@stdlib/ndarray/base/zeros-like' ) );
+ 
+ 
+// EXPORTS //
+ 
+module.exports = ns;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/base/slice/coverage.ndjson b/ndarray/base/slice/coverage.ndjson new file mode 100644 index 000000000..398f56a11 --- /dev/null +++ b/ndarray/base/slice/coverage.ndjson @@ -0,0 +1 @@ +[321,442,72.6244,6,6,100,0,5,0,321,442,72.6244,"fcbe4c18fd4ebfad0466b56b4c19abda6cdb4c2b","2023-09-26 14:05:25 -0700"] diff --git a/ndarray/base/slice/empty.js.html b/ndarray/base/slice/empty.js.html new file mode 100644 index 000000000..9a12b95e9 --- /dev/null +++ b/ndarray/base/slice/empty.js.html @@ -0,0 +1,253 @@ + + + + + + Code coverage report for ndarray/base/slice/lib/empty.js + + + + + + + + + +
+
+

All files / ndarray/base/slice/lib empty.js

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

+ 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 +571x +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 +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 buffer = require( '@stdlib/ndarray/base/buffer' );
+var zeros = require( '@stdlib/array/base/zeros' );
+var options = require( './options.js' );
+ 
+ 
+// MAIN //
+ 
+/**
+* Returns an empty n-dimensional ndarray.
+*
+* @private
+* @param {Function} ctor - ndarray constructor
+* @param {string} dtype - array data type
+* @param {NonNegativeIntegerArray} shape - array shape
+* @param {string} order - layout order
+* @returns {ndarray} empty ndarray
+*/
+function empty( ctor, dtype, shape, order ) {
+	var strides;
+	var ndims;
+
+	ndims = shape.length;
+	if ( ndims === 0 ) {
+		strides = [ 0 ];
+	} else {
+		strides = zeros( ndims );
+	}
+	return new ctor( dtype, buffer( dtype, 0 ), shape, strides, 0, order, options() ); // eslint-disable-line max-len
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = empty;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/base/slice/index.html b/ndarray/base/slice/index.html new file mode 100644 index 000000000..78f8888e9 --- /dev/null +++ b/ndarray/base/slice/index.html @@ -0,0 +1,191 @@ + + + + + + Code coverage report for ndarray/base/slice/lib + + + + + + + + + +
+
+

All files ndarray/base/slice/lib

+
+ +
+ 72.62% + Statements + 321/442 +
+ + +
+ 100% + Branches + 6/6 +
+ + +
+ 0% + Functions + 0/5 +
+ + +
+ 72.62% + Lines + 321/442 +
+ + +
+

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

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
empty.js +
+
78.57%44/56100%1/10%0/178.57%44/56
index.js +
+
100%67/67100%1/1100%0/0100%67/67
main.js +
+
52.79%85/161100%1/10%0/152.79%85/161
options.js +
+
84.61%33/39100%1/10%0/184.61%33/39
slice_start.js +
+
77.96%46/59100%1/10%0/177.96%46/59
slice_strides.js +
+
76.66%46/60100%1/10%0/176.66%46/60
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/base/slice/index.js.html b/ndarray/base/slice/index.js.html new file mode 100644 index 000000000..c8074f0d2 --- /dev/null +++ b/ndarray/base/slice/index.js.html @@ -0,0 +1,286 @@ + + + + + + Code coverage report for ndarray/base/slice/lib/index.js + + + + + + + + + +
+
+

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

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

+ 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 +681x +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 +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 a read-only view of an input ndarray.
+*
+* @module @stdlib/ndarray/base/slice
+*
+* @example
+* var Slice = require( '@stdlib/slice/ctor' );
+* var MultiSlice = require( '@stdlib/slice/multi' );
+* var ndarray = require( '@stdlib/ndarray/ctor' );
+* var ndarray2array = require( '@stdlib/ndarray/to-array' );
+* var slice = require( '@stdlib/ndarray/base/slice' );
+*
+* 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 x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
+* // returns <ndarray>
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns <MultiSlice>
+*
+* var y = slice( x, s, false );
+* // returns <ndarray>
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6.0, 5.0 ], [ 2.0, 1.0 ] ]
+*/
+ 
+// MODULES //
+ 
+var main = require( './main.js' );
+ 
+ 
+// EXPORTS //
+ 
+module.exports = main;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/base/slice/main.js.html b/ndarray/base/slice/main.js.html new file mode 100644 index 000000000..8c00d1d4f --- /dev/null +++ b/ndarray/base/slice/main.js.html @@ -0,0 +1,568 @@ + + + + + + Code coverage report for ndarray/base/slice/lib/main.js + + + + + + + + + +
+
+

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

+
+ +
+ 52.79% + Statements + 85/161 +
+ + +
+ 100% + Branches + 1/1 +
+ + +
+ 0% + Functions + 0/1 +
+ + +
+ 52.79% + Lines + 85/161 +
+ + +
+

+ 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 +1621x +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 +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 +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 normalizeMultiSlice = require( '@stdlib/slice/base/normalize-multi-slice' );
+var nonreducedDimensions = require( '@stdlib/slice/base/nonreduced-dimensions' );
+var sliceShape = require( '@stdlib/slice/base/shape' );
+var take = require( '@stdlib/array/base/take' );
+var zeros = require( '@stdlib/array/base/zeros' );
+var vind2bind = require( '@stdlib/ndarray/base/vind2bind' );
+var numel = require( '@stdlib/ndarray/base/numel' );
+var format = require( '@stdlib/string/format' );
+var sliceStart = require( './slice_start.js' );
+var slice2strides = require( './slice_strides.js' );
+var options = require( './options.js' );
+var empty = require( './empty.js' );
+ 
+ 
+// MAIN //
+ 
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param {ndarray} x - input array
+* @param {MultiSlice} s - multi-slice object
+* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking
+* @throws {RangeError} number of slice dimensions must match the number of array dimensions
+* @throws {RangeError} slice exceeds array bounds
+* @returns {ndarray} ndarray view
+*
+* @example
+* var Slice = require( '@stdlib/slice/ctor' );
+* var MultiSlice = require( '@stdlib/slice/multi' );
+* var ndarray = require( '@stdlib/ndarray/ctor' );
+* var ndarray2array = require( '@stdlib/ndarray/to-array' );
+*
+* 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 x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
+* // returns <ndarray>
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns <MultiSlice>
+*
+* var y = slice( x, s, false );
+* // returns <ndarray>
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6.0, 5.0 ], [ 2.0, 1.0 ] ]
+*/
+function slice( x, s, strict ) {
+	var strides;
+	var offset;
+	var dtype;
+	var shape;
+	var order;
+	var sdims;
+	var ndims;
+	var ctor;
+	var sh;
+	var ns;
+
+	// Retrieve array meta data:
+	dtype = x.dtype;
+	shape = x.shape;
+	strides = x.strides;
+	offset = x.offset;
+	order = x.order;
+	ndims = shape.length;
+
+	// Ensure that the number of array dimensions matches the number of slices:
+	if ( s.ndims !== ndims ) {
+		throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', shape.join( ',' ), s.ndims ) );
+	}
+	// Resolve the output array constructor:
+	ctor = x.constructor;
+
+	// If provided a zero-dimensional input array, return a zero-dimensional array view...
+	if ( ndims === 0 ) {
+		return new ctor( dtype, x.data, shape, strides, offset, order, options() ); // eslint-disable-line max-len
+	}
+	// Resolve the indices of the non-reduced dimensions:
+	sdims = nonreducedDimensions( s );
+
+	// Normalize the slice object based on the array shape:
+	ns = normalizeMultiSlice( s, shape, true );
+
+	// Check whether the slice exceeds array bounds...
+	if ( ns.code ) {
+		if ( strict ) {
+			throw new RangeError( format( 'invalid argument. Slice exceeds array bounds. Array shape: (%s).', shape.join( ',' ) ) );
+		}
+		// Normalize again, this time allowing for out-of-bounds indices:
+		ns = normalizeMultiSlice( s, shape, false );
+
+		// Compute the slice shape:
+		sh = sliceShape( ns );
+
+		// If the non-reduced dimensions contain elements, this means that at least one reduced dimension exceeded array bounds; in which case, we generate a shape containing zeros:
+		if ( numel( take( sh, sdims ) ) > 0 ) {
+			sh = zeros( sh.length );
+		}
+	} else {
+		// Compute the slice shape:
+		sh = sliceShape( ns );
+	}
+	// If the slice does not contain any elements, return an empty array...
+	if ( numel( sh ) === 0 ) {
+		return empty( ctor, dtype, take( sh, sdims ), order );
+	}
+	// Resolve the index offset of the first element indexed by the slice:
+	offset = vind2bind( shape, strides, offset, order, sliceStart( ns, shape, strides, 0 ), 'throw' ); // TODO: @stdlib/ndarray/base/sind2bind
+
+	// Remove reduced dimensions from the slice shape:
+	sh = take( sh, sdims );
+
+	// If all dimensions were reduced, return a zero-dimensional array...
+	if ( sh.length === 0 ) {
+		return new ctor( dtype, x.data, [], [ 0 ], offset, order, options() );
+	}
+	// Update strides according to slice steps:
+	strides = slice2strides( ns, strides, sdims ); // TODO: @stdlib/ndarray/base/slice2strides???
+
+	// Return a slice view:
+	return new ctor( dtype, x.data, sh, strides, offset, order, options() );
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = slice;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/base/slice/options.js.html b/ndarray/base/slice/options.js.html new file mode 100644 index 000000000..837a80ff8 --- /dev/null +++ b/ndarray/base/slice/options.js.html @@ -0,0 +1,202 @@ + + + + + + Code coverage report for ndarray/base/slice/lib/options.js + + + + + + + + + +
+
+

All files / ndarray/base/slice/lib options.js

+
+ +
+ 84.61% + Statements + 33/39 +
+ + +
+ 100% + Branches + 1/1 +
+ + +
+ 0% + Functions + 0/1 +
+ + +
+ 84.61% + Lines + 33/39 +
+ + +
+

+ 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 +401x +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';
+ 
+// MAIN //
+ 
+/**
+* Returns array creation options.
+*
+* @private
+* @returns {Object} options
+*/
+function options() {
+	return {
+		// Default to always returning read-only arrays:
+		'readonly': true
+	};
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = options;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/base/slice/slice_start.js.html b/ndarray/base/slice/slice_start.js.html new file mode 100644 index 000000000..a306d5e70 --- /dev/null +++ b/ndarray/base/slice/slice_start.js.html @@ -0,0 +1,262 @@ + + + + + + Code coverage report for ndarray/base/slice/lib/slice_start.js + + + + + + + + + +
+
+

All files / ndarray/base/slice/lib slice_start.js

+
+ +
+ 77.96% + Statements + 46/59 +
+ + +
+ 100% + Branches + 1/1 +
+ + +
+ 0% + Functions + 0/1 +
+ + +
+ 77.96% + Lines + 46/59 +
+ + +
+

+ 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 +601x +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 +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 sub2ind = require( '@stdlib/ndarray/base/sub2ind' );
+ 
+ 
+// MAIN //
+ 
+/**
+* Resolves the linear index of the first element indexed by a normalized multi-slice.
+*
+* ## Notes
+*
+* -   If `strides` contains negative strides, if an `offset` is greater than `0`, the function returns a linear index with respect to the underlying data buffer. If an `offset` is equal to `0`, the function returns a linear index with respect to the array view. For more information, see `@stdlib/ndarray/base/sub2ind`.
+*
+* @private
+* @param {MultiSlice} slice - normalized multi-slice object
+* @param {NonNegativeIntegerArray} shape - array shape
+* @param {IntegerArray} strides - array strides
+* @param {NonNegativeInteger} offset - index offset
+* @returns {NonNegativeInteger} linear index of the first element
+*/
+function sliceStart( slice, shape, strides, offset ) {
+	var data;
+	var args;
+	var i;
+
+	data = slice.data;
+	args = [ shape, strides, offset ];
+	for ( i = 0; i < data.length; i++ ) {
+		args.push( data[ i ].start );
+	}
+	args.push( 'throw' );
+	return sub2ind.apply( null, args );
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = sliceStart;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/base/slice/slice_strides.js.html b/ndarray/base/slice/slice_strides.js.html new file mode 100644 index 000000000..63c2e09b9 --- /dev/null +++ b/ndarray/base/slice/slice_strides.js.html @@ -0,0 +1,265 @@ + + + + + + Code coverage report for ndarray/base/slice/lib/slice_strides.js + + + + + + + + + +
+
+

All files / ndarray/base/slice/lib slice_strides.js

+
+ +
+ 76.66% + Statements + 46/60 +
+ + +
+ 100% + Branches + 1/1 +
+ + +
+ 0% + Functions + 0/1 +
+ + +
+ 76.66% + Lines + 46/60 +
+ + +
+

+ 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 +611x +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 +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 //
+ 
+/**
+* Resolves slice strides for a provided normalized multi-slice object.
+*
+* @private
+* @param {MultiSlice} slice - normalized multi-slice object
+* @param {IntegerArray} strides - array strides
+* @param {NonNegativeIntegerArray} rdims - indices of non-reduced dimensions
+* @returns {IntegerArray} slice strides
+*
+* @example
+* var Slice = require( '@stdlib/slice/ctor' );
+* var MultiSlice = require( '@stdlib/slice/multi' );
+*
+* var s = new MultiSlice( new Slice( 2, 3, 1 ), new Slice( 10, null, -2 ) );
+* // returns <MultiSlice>
+*
+* var strides = slice2strides( s, [ 8, 2 ], [ 1 ] );
+* // returns [ -4 ]
+*/
+function slice2strides( slice, strides, rdims ) {
+	var data;
+	var out;
+	var i;
+	var j;
+
+	data = slice.data;
+	out = [];
+	for ( i = 0; i < rdims.length; i++ ) {
+		j = rdims[ i ];
+		out.push( strides[j] * data[j].step );
+	}
+	return out;
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = slice2strides;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/fancy/coverage.ndjson b/ndarray/fancy/coverage.ndjson index caf584b0a..9de0b71bd 100644 --- a/ndarray/fancy/coverage.ndjson +++ b/ndarray/fancy/coverage.ndjson @@ -4,3 +4,4 @@ [829,1288,64.3634,27,29,93.1034,1,12,8.33333,829,1288,64.3634,"6d60c74f1eb464d2d3875943c75a1c4b04239984","2023-09-19 13:11:22 -0700"] [829,1288,64.3634,27,29,93.1034,1,12,8.33333,829,1288,64.3634,"f4024f0d2c13cb5c74917228231ae9f6a9793a50","2023-09-19 13:13:04 -0700"] [740,1179,62.7651,25,27,92.5926,1,10,10,740,1179,62.7651,"f5f669fe49db4cb57103fb1c5f4ba2532bf9011b","2023-09-23 22:50:57 -0700"] +[562,867,64.8212,21,23,91.3043,1,6,16.6667,562,867,64.8212,"fcbe4c18fd4ebfad0466b56b4c19abda6cdb4c2b","2023-09-26 14:05:25 -0700"] diff --git a/ndarray/fancy/error_constructor.js.html b/ndarray/fancy/error_constructor.js.html new file mode 100644 index 000000000..b0bdcb555 --- /dev/null +++ b/ndarray/fancy/error_constructor.js.html @@ -0,0 +1,244 @@ + + + + + + Code coverage report for ndarray/fancy/lib/error_constructor.js + + + + + + + + + +
+
+

All files / ndarray/fancy/lib error_constructor.js

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

+ 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 +542x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +  +  +  +  +  +  +  +  +  +  +  +  +2x +2x +2x +2x +2x + 
/**
+* @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 isRangeError = require( '@stdlib/assert/is-range-error' );
+var isTypeError = require( '@stdlib/assert/is-type-error' );
+var isSyntaxError = require( '@stdlib/assert/is-syntax-error' );
+ 
+ 
+// MAIN //
+ 
+/**
+* Returns the error constructor for a provided error object.
+*
+* @private
+* @param {Error} err - error object
+* @returns {Function} error constructor
+*/
+function errConstructor( err ) {
+	if ( isRangeError( err ) ) {
+		return RangeError;
+	}
+	if ( isTypeError( err ) ) {
+		return TypeError;
+	}
+	if ( isSyntaxError( err ) ) {
+		return SyntaxError;
+	}
+	return Error;
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = errConstructor;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/fancy/error_message.js.html b/ndarray/fancy/error_message.js.html new file mode 100644 index 000000000..9561d8757 --- /dev/null +++ b/ndarray/fancy/error_message.js.html @@ -0,0 +1,211 @@ + + + + + + Code coverage report for ndarray/fancy/lib/error_message.js + + + + + + + + + +
+
+

All files / ndarray/fancy/lib error_message.js

+
+ +
+ 92.85% + Statements + 39/42 +
+ + +
+ 100% + Branches + 1/1 +
+ + +
+ 0% + Functions + 0/1 +
+ + +
+ 92.85% + Lines + 39/42 +
+ + +
+

+ 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 +432x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +  +  +  +2x +2x +2x +2x +2x + 
/**
+* @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 replace = require( '@stdlib/string/base/replace' );
+ 
+ 
+// MAIN //
+ 
+/**
+* Returns an updated error message for trapped errors.
+*
+* @private
+* @param {string} msg - error message
+* @returns {string} updated message
+*/
+function errMessage( msg ) {
+	return replace( msg, /^invalid argument/, 'invalid operation' );
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = errMessage;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/ndarray/fancy/get.0d.js.html b/ndarray/fancy/get.0d.js.html index 8b82ffe69..0192c9a06 100644 --- a/ndarray/fancy/get.0d.js.html +++ b/ndarray/fancy/get.0d.js.html @@ -23,9 +23,9 @@

All files / ndarray/f
- 41.52% + 37.08% Statements - 49/118 + 56/151
@@ -44,9 +44,9 @@

All files / ndarray/f
- 41.52% + 37.08% Lines - 49/118 + 56/151
@@ -181,7 +181,40 @@

All files / ndarray/f 116 117 118 -1192x +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 +1522x 2x 2x 2x @@ -225,6 +258,39 @@

All files / ndarray/f 2x 2x 2x +2x +2x +2x +2x +2x +2x +2x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +        @@ -323,11 +389,18 @@

All files / ndarray/f   var isFunction = require( '@stdlib/assert/is-function' ); var trim = require( '@stdlib/string/base/trim' ); +var replace = require( '@stdlib/string/base/replace' ); +var MultiSlice = require( '@stdlib/slice/multi' ); var str2multislice = require( '@stdlib/slice/base/str2multislice' ); +var seq2multislice = require( '@stdlib/slice/base/seq2multislice' ); +var str2slice = require( '@stdlib/slice/base/str2slice' ); +var slice = require( '@stdlib/ndarray/base/slice' ); var format = require( '@stdlib/string/format' ); +var errMessage = require( './error_message.js' ); +var errConstructor = require( './error_constructor.js' ); var hasProperty = require( './has_property.js' ); -var options = require( './array_options.js' ); var RE_INTEGER = require( './re_integer.js' ); +var RE_SUBSEQ = require( './re_subseq.js' );     // MAIN // @@ -343,12 +416,12 @@

All files / ndarray/f * @throws {RangeError} number of slice dimensions must match the number of array dimensions * @returns {*} result */ -function get( target, property, receiver ) { - var dtype; +function get( target, property, receiver ) { // eslint-disable-line stdlib/jsdoc-require-throws-tags var value; + var shape; var prop; var ch; - var sh; + var E; var s; if ( hasProperty( property ) ) { value = target[ property ]; @@ -359,41 +432,67 @@

All files / ndarray/f } prop = trim( property ); - // Resolve target meta data: - dtype = target.dtype; - sh = target.shape; - // Retrieve the first character in order to to detect how a slice operation was specified: ch = prop[ 0 ]; + // Case: slice + if ( ch === 'S' ) { + // Convert the string to a slice object: + s = str2slice( property ); + if ( s === null ) { + throw new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', property ) ); + } + // Create a multi-slice: + s = new MultiSlice( s ); + } // Case: multi-slice - if ( ch === 'M' ) { + else if ( ch === 'M' ) { // Convert the string to a slice object: s = str2multislice( prop ); if ( s === null ) { throw new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', property ) ); } - // TODO: => @stdlib/ndarray/base/slice: return slice( receiver, s.data ); + } + // Case: integer + else if ( RE_INTEGER.test( prop ) ) { + // Convert the string to a numeric value: + s = parseInt( prop, 10 ); - // Ensure that we were provided an empty multi-slice: - if ( s.ndims !== sh.length ) { - throw new RangeError( format( 'invalid operation. Number of array dimensions does not match the number of slice dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), s.ndims ) ); + // Create a multi-slice: + s = new MultiSlice( s ); + } + // Case: subsequence string (e.g., ':10,1,::-1,:,-5,2::3') + else if ( RE_SUBSEQ.test( prop ) ) { + shape = target.shape; + s = seq2multislice( prop, shape, true ); + if ( s.code ) { + if ( s.code === 'ERR_SLICE_INVALID_INCREMENT' ) { + throw new Error( format( 'invalid operation. A subsequence increment must be a non-zero integer. Value: `%s`.', property ) ); + } + if ( s.code === 'ERR_SLICE_INVALID_ELLIPSIS' ) { + throw new Error( format( 'invalid operation. A subsequence may only include a single ellipsis. Value: `%s`.', property ) ); + } + if ( s.code === 'ERR_SLICE_INVALID_SUBSEQUENCE' ) { + throw new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', property ) ); + } + // s.code === 'ERR_SLICE_TOO_MANY_DIMENSIONS' + throw new RangeError( format( 'invalid operation. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', shape.join( ',' ), replace( prop, /\.\.\.,/, '' ).split( ',' ).length ) ); } } + // Case: empty string or ellipsis + else if ( prop.length === 0 || prop === '...' ) { + s = new MultiSlice(); + } // Case: non-empty string - else if ( prop.length !== 0 ) { - // TODO: the following can be generalized by going ahead and parsing the slice string or integer and passing to a functional API which then verifies that s.ndims !== sh.length. We need only retain the error raised for an invalid operation. - - // Case: slice or an integer - if ( ch === 'S' || RE_INTEGER.test( prop ) ) { - throw new RangeError( format( 'invalid operation. Number of array dimensions does not match the number of slice dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 1 ) ); - } + else { throw new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', property ) ); } - // TODO: => @stdlib/ndarray/base/slice: return slice( receiver, [] ); - - // Return an zero-dimensional array view: - return new receiver.constructor( dtype, target.data, sh, target.strides, target.offset, target.order, options() ); // eslint-disable-line max-len + try { + return slice( receiver, s, true ); + } catch ( err ) { + E = errConstructor( err ); + throw new E( errMessage( err.message ) ); + } /** * Method wrapper. @@ -424,7 +523,7 @@

All files / ndarray/f