@stdlib/ndarray-zeros-like 0.2.1 → 0.3.0

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/README.md CHANGED
@@ -85,7 +85,7 @@ var dt = y.dtype;
85
85
 
86
86
  The function supports the following `options`:
87
87
 
88
- - **dtype**: output [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes]. Overrides the input ndarray's inferred [data type][@stdlib/ndarray/dtypes].
88
+ - **dtype**: output [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes]. Must be a numeric [data type][@stdlib/ndarray/dtypes] or "generic". Overrides the input ndarray's inferred [data type][@stdlib/ndarray/dtypes].
89
89
  - **shape**: output [ndarray][@stdlib/ndarray/ctor] shape. Overrides the input ndarray's inferred shape.
90
90
  - **order**: specifies whether the output [ndarray][@stdlib/ndarray/ctor] should be `'row-major'` (C-style) or `'column-major'` (Fortran-style). Overrides the input ndarray's inferred order.
91
91
  - **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`.
@@ -141,7 +141,7 @@ var zeros = require( '@stdlib/ndarray-zeros' );
141
141
  var zerosLike = require( '@stdlib/ndarray-zeros-like' );
142
142
 
143
143
  // Get a list of data types:
144
- var dt = dtypes();
144
+ var dt = dtypes( 'numeric' );
145
145
 
146
146
  // Generate zero-filled arrays...
147
147
  var x;
@@ -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.2.1
226
- [test-url]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml?query=branch:v0.2.1
225
+ [test-image]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml/badge.svg?branch=v0.3.0
226
+ [test-url]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml?query=branch:v0.3.0
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
@@ -22,7 +22,7 @@
22
22
 
23
23
  /// <reference types="@stdlib/types"/>
24
24
 
25
- import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray';
25
+ import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray';
26
26
 
27
27
  /**
28
28
  * Interface describing function options.
@@ -216,6 +216,20 @@ interface Uint8COptions extends Options {
216
216
  dtype: 'uint8c';
217
217
  }
218
218
 
219
+ /**
220
+ * Interface describing function options.
221
+ */
222
+ interface GenericOptions extends Options {
223
+ /**
224
+ * Underlying data type.
225
+ *
226
+ * ## Notes
227
+ *
228
+ * - This option overrides the input array's inferred data type.
229
+ */
230
+ dtype: 'generic';
231
+ }
232
+
219
233
  /**
220
234
  * Interface describing function options.
221
235
  */
@@ -227,7 +241,7 @@ interface OptionsWithDType extends Options {
227
241
  *
228
242
  * - This option overrides the input array's inferred data type.
229
243
  */
230
- dtype: DataType;
244
+ dtype: NumericAndGenericDataType;
231
245
  }
232
246
 
233
247
  /**
@@ -637,6 +651,43 @@ declare function zerosLike( x: uint8ndarray, options?: Options ): uint8ndarray;
637
651
  */
638
652
  declare function zerosLike( x: uint8cndarray, options?: Options ): uint8cndarray;
639
653
 
654
+ /**
655
+ * Creates a zero-filled array having the same shape and data type as a provided input ndarray.
656
+ *
657
+ * @param x - input array
658
+ * @param options - options
659
+ * @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
660
+ * @param options.shape - output array shape
661
+ * @param options.mode - specifies how to handle a linear index which exceeds array dimensions
662
+ * @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
663
+ * @param options.readonly - boolean indicating whether an array should be read-only
664
+ * @returns zero-filled array
665
+ *
666
+ * @example
667
+ * var zeros = require( '@stdlib/ndarray-zeros' );
668
+ *
669
+ * var x = zeros( [ 2, 2 ], {
670
+ * 'dtype': 'generic'
671
+ * });
672
+ * // returns <ndarray>
673
+ *
674
+ * var sh = x.shape;
675
+ * // returns [ 2, 2 ]
676
+ *
677
+ * var dt = x.dtype;
678
+ * // returns 'generic'
679
+ *
680
+ * var y = zerosLike( x );
681
+ * // returns <ndarray>
682
+ *
683
+ * sh = y.shape;
684
+ * // returns [ 2, 2 ]
685
+ *
686
+ * dt = y.dtype;
687
+ * // returns 'generic'
688
+ */
689
+ declare function zerosLike( x: genericndarray<any>, options?: Options ): genericndarray<number>;
690
+
640
691
  /**
641
692
  * Creates a zero-filled double-precision floating-point array having the same shape as a provided input ndarray.
642
693
  *
@@ -1077,6 +1128,46 @@ declare function zerosLike( x: ndarray, options: Uint8Options ): uint8ndarray;
1077
1128
  */
1078
1129
  declare function zerosLike( x: ndarray, options: Uint8COptions ): uint8cndarray;
1079
1130
 
1131
+ /**
1132
+ * Creates a zero-filled generic array having the same shape as a provided input ndarray.
1133
+ *
1134
+ * @param x - input array
1135
+ * @param options - options
1136
+ * @param options.dtype - output array data type
1137
+ * @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
1138
+ * @param options.shape - output array shape
1139
+ * @param options.mode - specifies how to handle a linear index which exceeds array dimensions
1140
+ * @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
1141
+ * @param options.readonly - boolean indicating whether an array should be read-only
1142
+ * @returns zero-filled array
1143
+ *
1144
+ * @example
1145
+ * var zeros = require( '@stdlib/ndarray-zeros' );
1146
+ *
1147
+ * var x = zeros( [ 2, 2 ], {
1148
+ * 'dtype': 'float64'
1149
+ * });
1150
+ * // returns <ndarray>
1151
+ *
1152
+ * var sh = x.shape;
1153
+ * // returns [ 2, 2 ]
1154
+ *
1155
+ * var dt = x.dtype;
1156
+ * // returns 'float64'
1157
+ *
1158
+ * var y = zerosLike( x, {
1159
+ * 'dtype': 'generic'
1160
+ * });
1161
+ * // returns <ndarray>
1162
+ *
1163
+ * sh = y.shape;
1164
+ * // returns [ 2, 2 ]
1165
+ *
1166
+ * dt = y.dtype;
1167
+ * // returns 'generic'
1168
+ */
1169
+ declare function zerosLike( x: ndarray, options: GenericOptions ): genericndarray<number>;
1170
+
1080
1171
  /**
1081
1172
  * Creates a zero-filled array having the same shape and data type as a provided input ndarray.
1082
1173
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/ndarray-zeros-like",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
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": {
@@ -30,20 +30,20 @@
30
30
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@stdlib/assert-has-own-property": "^0.2.1",
34
- "@stdlib/assert-is-ndarray-like": "^0.2.1",
35
- "@stdlib/assert-is-nonnegative-integer-array": "^0.2.1",
36
- "@stdlib/assert-is-plain-object": "^0.2.1",
33
+ "@stdlib/assert-has-own-property": "^0.2.2",
34
+ "@stdlib/assert-is-ndarray-like": "^0.2.2",
35
+ "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2",
36
+ "@stdlib/assert-is-plain-object": "^0.2.2",
37
37
  "@stdlib/ndarray-base-buffer": "^0.2.1",
38
- "@stdlib/ndarray-base-numel": "^0.2.1",
39
- "@stdlib/ndarray-base-shape2strides": "^0.2.1",
40
- "@stdlib/ndarray-base-strides2offset": "^0.2.1",
38
+ "@stdlib/ndarray-base-numel": "^0.2.2",
39
+ "@stdlib/ndarray-base-shape2strides": "^0.2.2",
40
+ "@stdlib/ndarray-base-strides2offset": "^0.2.2",
41
41
  "@stdlib/ndarray-ctor": "^0.2.1",
42
42
  "@stdlib/ndarray-dtype": "^0.2.1",
43
- "@stdlib/ndarray-order": "^0.2.1",
44
- "@stdlib/ndarray-shape": "^0.2.1",
45
- "@stdlib/string-format": "^0.2.1",
46
- "@stdlib/error-tools-fmtprodmsg": "^0.2.1"
43
+ "@stdlib/ndarray-order": "^0.2.2",
44
+ "@stdlib/ndarray-shape": "^0.2.2",
45
+ "@stdlib/string-format": "^0.2.2",
46
+ "@stdlib/error-tools-fmtprodmsg": "^0.2.2"
47
47
  },
48
48
  "devDependencies": {},
49
49
  "engines": {