@stdlib/ndarray-zeros-like 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/README.md +6 -6
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/docs/types/index.d.ts +2 -2
- package/lib/main.js +4 -2
- package/package.json +6 -4
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -92,7 +92,7 @@ The function supports the following `options`:
|
|
|
92
92
|
- **submode**: a mode array which specifies for each dimension how to handle subscripts which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). If provided fewer modes than dimensions, the constructor recycles modes using modulo arithmetic. Default: `[ options.mode ]`.
|
|
93
93
|
- **readonly**: `boolean` indicating whether an array should be **read-only**. Default: `false`.
|
|
94
94
|
|
|
95
|
-
To override either the `dtype`, `shape`, or `order`, specify the corresponding option. For example, to override the inferred [data type][@stdlib/ndarray/dtypes],
|
|
95
|
+
To override either the `dtype`, `shape`, or `order`, specify the corresponding option. For example, to override the inferred [data type][@stdlib/ndarray/dtypes],
|
|
96
96
|
|
|
97
97
|
```javascript
|
|
98
98
|
var zeros = require( '@stdlib/ndarray-zeros' );
|
|
@@ -209,7 +209,7 @@ See [LICENSE][stdlib-license].
|
|
|
209
209
|
|
|
210
210
|
## Copyright
|
|
211
211
|
|
|
212
|
-
Copyright © 2016-
|
|
212
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
213
213
|
|
|
214
214
|
</section>
|
|
215
215
|
|
|
@@ -222,8 +222,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
222
222
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/ndarray-zeros-like.svg
|
|
223
223
|
[npm-url]: https://npmjs.org/package/@stdlib/ndarray-zeros-like
|
|
224
224
|
|
|
225
|
-
[test-image]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml/badge.svg?branch=v0.3.
|
|
226
|
-
[test-url]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml?query=branch:v0.3.
|
|
225
|
+
[test-image]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml/badge.svg?branch=v0.3.1
|
|
226
|
+
[test-url]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml?query=branch:v0.3.1
|
|
227
227
|
|
|
228
228
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-zeros-like/main.svg
|
|
229
229
|
[coverage-url]: https://codecov.io/github/stdlib-js/ndarray-zeros-like?branch=main
|
|
@@ -235,8 +235,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
235
235
|
|
|
236
236
|
-->
|
|
237
237
|
|
|
238
|
-
[chat-image]: https://img.shields.io/
|
|
239
|
-
[chat-url]: https://
|
|
238
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
239
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
240
240
|
|
|
241
241
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
242
242
|
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
var
|
|
1
|
+
"use strict";var q=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var y=q(function(F,g){
|
|
2
|
+
var h=require('@stdlib/assert-is-number/dist').isPrimitive,b=require('@stdlib/assert-is-ndarray-like/dist'),w=require('@stdlib/assert-is-plain-object/dist'),c=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,E=require('@stdlib/assert-is-empty-collection/dist'),t=require('@stdlib/assert-has-own-property/dist'),O=require('@stdlib/ndarray-base-shape2strides/dist'),T=require('@stdlib/ndarray-base-strides2offset/dist'),j=require('@stdlib/ndarray-base-buffer/dist'),k=require('@stdlib/ndarray-base-numel/dist'),l=require('@stdlib/ndarray-dtype/dist'),p=require('@stdlib/ndarray-shape/dist'),f=require('@stdlib/ndarray-order/dist'),N=require('@stdlib/ndarray-ctor/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function P(i){var e,a,n,m,s,v,d,o,r;if(!b(i))throw new TypeError(u('0kH5t',i));if(s={},arguments.length>1){if(e=arguments[1],!w(e))throw new TypeError(u('0kH2V',e));if(t(e,"dtype")?a=e.dtype:a=l(i),t(e,"shape")){if(r=e.shape,h(r)&&(r=[r]),!c(r)&&!E(r))throw new TypeError(u('0kHDs',"shape",r))}else r=p(i);t(e,"order")?n=e.order:n=f(i),t(e,"mode")&&(s.mode=e.mode),t(e,"submode")&&(s.submode=e.submode),t(e,"readonly")&&(s.readonly=e.readonly)}else a=l(i),r=p(i),n=f(i);if(m=r.length,m>0?(d=k(r),o=O(r,n)):(d=1,o=[0]),v=j(a,d),v===null)throw new TypeError(u('0kH5L',a));return new N(a,v,r,o,T(r,o),n,s)}g.exports=P
|
|
3
3
|
});var V=y();module.exports=V;
|
|
4
4
|
/** @license Apache-2.0 */
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/main.js", "../lib/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns <ndarray>\n*\n* var y = zerosLike( x );\n* // returns <ndarray>\n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction zerosLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif (
|
|
5
|
-
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,
|
|
6
|
-
"names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "buffer", "numel", "getDType", "getShape", "getOrder", "ndarray", "format", "zerosLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"]
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns <ndarray>\n*\n* var y = zerosLike( x );\n* // returns <ndarray>\n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction zerosLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( isNumber( sh ) ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) && !isEmptyCollection( sh ) ) { // eslint-disable-line max-len\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must have a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zerosLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-zeros-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var zerosLike = require( '@stdlib/ndarray-zeros-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns <ndarray>\n*\n* var y = zerosLike( x );\n* // returns <ndarray>\n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAoB,QAAS,oCAAqC,EAClEC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKZ,EAAYY,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQR,EAAUM,CAAE,EAEhBX,EAAYY,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACRjB,EAAUyB,CAAG,IACjBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,GAAK,CAACrB,EAAmBqB,CAAG,EAC/D,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKd,EAAUK,CAAE,EAEbX,EAAYY,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQP,EAAUI,CAAE,EAEhBX,EAAYY,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBZ,EAAYY,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBZ,EAAYY,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQR,EAAUM,CAAE,EACpBS,EAAKd,EAAUK,CAAE,EACjBG,EAAQP,EAAUI,CAAE,EAYrB,GAVAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMd,EAAOgB,CAAG,EAChBD,EAAKlB,EAAemB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,kFAAmFI,CAAM,CAAE,EAEzH,OAAO,IAAIL,EAASK,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAtB,EAAO,QAAUgB,ICzGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "isNumber", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "isEmptyCollection", "hasOwnProp", "shape2strides", "strides2offset", "buffer", "numel", "getDType", "getShape", "getOrder", "ndarray", "format", "zerosLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"]
|
|
7
7
|
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -1193,7 +1193,7 @@ declare function zerosLike( x: ndarray, options: GenericOptions ): genericndarra
|
|
|
1193
1193
|
* // returns [ 2, 2 ]
|
|
1194
1194
|
*
|
|
1195
1195
|
* var dt = x.dtype;
|
|
1196
|
-
* // returns '
|
|
1196
|
+
* // returns 'float64'
|
|
1197
1197
|
*
|
|
1198
1198
|
* var y = zerosLike( x );
|
|
1199
1199
|
* // returns <ndarray>
|
|
@@ -1202,7 +1202,7 @@ declare function zerosLike( x: ndarray, options: GenericOptions ): genericndarra
|
|
|
1202
1202
|
* // returns [ 2, 2 ]
|
|
1203
1203
|
*
|
|
1204
1204
|
* dt = y.dtype;
|
|
1205
|
-
* // returns '
|
|
1205
|
+
* // returns 'float64'
|
|
1206
1206
|
*/
|
|
1207
1207
|
declare function zerosLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray<number>;
|
|
1208
1208
|
|
package/lib/main.js
CHANGED
|
@@ -20,9 +20,11 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
+
var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;
|
|
23
24
|
var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );
|
|
24
25
|
var isPlainObject = require( '@stdlib/assert-is-plain-object' );
|
|
25
26
|
var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;
|
|
27
|
+
var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );
|
|
26
28
|
var hasOwnProp = require( '@stdlib/assert-has-own-property' );
|
|
27
29
|
var shape2strides = require( '@stdlib/ndarray-base-shape2strides' );
|
|
28
30
|
var strides2offset = require( '@stdlib/ndarray-base-strides2offset' );
|
|
@@ -98,10 +100,10 @@ function zerosLike( x ) {
|
|
|
98
100
|
}
|
|
99
101
|
if ( hasOwnProp( options, 'shape' ) ) {
|
|
100
102
|
sh = options.shape;
|
|
101
|
-
if (
|
|
103
|
+
if ( isNumber( sh ) ) {
|
|
102
104
|
sh = [ sh ];
|
|
103
105
|
}
|
|
104
|
-
if ( !isNonNegativeIntegerArray( sh ) ) {
|
|
106
|
+
if ( !isNonNegativeIntegerArray( sh ) && !isEmptyCollection( sh ) ) { // eslint-disable-line max-len
|
|
105
107
|
throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );
|
|
106
108
|
}
|
|
107
109
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/ndarray-zeros-like",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Create a zero-filled ndarray having the same shape and data type as a provided ndarray.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -31,15 +31,17 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@stdlib/assert-has-own-property": "^0.2.2",
|
|
34
|
+
"@stdlib/assert-is-empty-collection": "^0.2.3",
|
|
34
35
|
"@stdlib/assert-is-ndarray-like": "^0.2.2",
|
|
35
36
|
"@stdlib/assert-is-nonnegative-integer-array": "^0.2.2",
|
|
37
|
+
"@stdlib/assert-is-number": "^0.2.2",
|
|
36
38
|
"@stdlib/assert-is-plain-object": "^0.2.2",
|
|
37
|
-
"@stdlib/ndarray-base-buffer": "^0.
|
|
39
|
+
"@stdlib/ndarray-base-buffer": "^0.3.0",
|
|
38
40
|
"@stdlib/ndarray-base-numel": "^0.2.2",
|
|
39
41
|
"@stdlib/ndarray-base-shape2strides": "^0.2.2",
|
|
40
42
|
"@stdlib/ndarray-base-strides2offset": "^0.2.2",
|
|
41
|
-
"@stdlib/ndarray-ctor": "^0.2.
|
|
42
|
-
"@stdlib/ndarray-dtype": "^0.2.
|
|
43
|
+
"@stdlib/ndarray-ctor": "^0.2.2",
|
|
44
|
+
"@stdlib/ndarray-dtype": "^0.2.2",
|
|
43
45
|
"@stdlib/ndarray-order": "^0.2.2",
|
|
44
46
|
"@stdlib/ndarray-shape": "^0.2.2",
|
|
45
47
|
"@stdlib/string-format": "^0.2.2",
|