@stdlib/ndarray-zeros-like 0.0.1 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/ndarray-zeros-like",
3
- "version": "0.0.1",
3
+ "version": "0.2.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": {
@@ -37,40 +37,46 @@
37
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@stdlib/assert-has-own-property": "^0.0.x",
41
- "@stdlib/assert-is-ndarray-like": "^0.0.x",
42
- "@stdlib/assert-is-nonnegative-integer-array": "^0.0.x",
43
- "@stdlib/assert-is-plain-object": "^0.0.x",
44
- "@stdlib/ndarray-base-buffer": "^0.0.x",
45
- "@stdlib/ndarray-base-numel": "^0.0.x",
46
- "@stdlib/ndarray-base-shape2strides": "^0.0.x",
47
- "@stdlib/ndarray-base-strides2offset": "^0.0.x",
48
- "@stdlib/ndarray-ctor": "^0.0.x",
49
- "@stdlib/types": "^0.0.x"
40
+ "@stdlib/assert-has-own-property": "^0.2.0",
41
+ "@stdlib/assert-is-ndarray-like": "^0.2.0",
42
+ "@stdlib/assert-is-nonnegative-integer-array": "^0.2.0",
43
+ "@stdlib/assert-is-plain-object": "^0.2.0",
44
+ "@stdlib/ndarray-base-buffer": "^0.2.0",
45
+ "@stdlib/ndarray-base-numel": "^0.2.0",
46
+ "@stdlib/ndarray-base-shape2strides": "^0.2.0",
47
+ "@stdlib/ndarray-base-strides2offset": "^0.2.0",
48
+ "@stdlib/ndarray-ctor": "^0.2.0",
49
+ "@stdlib/ndarray-dtype": "^0.2.0",
50
+ "@stdlib/ndarray-order": "^0.2.0",
51
+ "@stdlib/ndarray-shape": "^0.2.0",
52
+ "@stdlib/string-format": "^0.2.0",
53
+ "@stdlib/types": "^0.3.1",
54
+ "@stdlib/error-tools-fmtprodmsg": "^0.2.0"
50
55
  },
51
56
  "devDependencies": {
52
- "@stdlib/array-complex128": "^0.0.x",
53
- "@stdlib/array-complex64": "^0.0.x",
54
- "@stdlib/array-float32": "^0.0.x",
55
- "@stdlib/array-float64": "^0.0.x",
56
- "@stdlib/array-int16": "^0.0.x",
57
- "@stdlib/array-int32": "^0.0.x",
58
- "@stdlib/array-int8": "^0.0.x",
59
- "@stdlib/array-uint16": "^0.0.x",
60
- "@stdlib/array-uint32": "^0.0.x",
61
- "@stdlib/array-uint8": "^0.0.x",
62
- "@stdlib/array-uint8c": "^0.0.x",
63
- "@stdlib/assert-instance-of": "^0.0.x",
64
- "@stdlib/bench": "^0.0.x",
65
- "@stdlib/math-base-special-pow": "^0.0.x",
66
- "@stdlib/ndarray-base-zeros": "^0.0.x",
67
- "@stdlib/ndarray-dtypes": "^0.0.x",
68
- "@stdlib/ndarray-zeros": "^0.0.x",
69
- "@stdlib/strided-base-reinterpret-complex128": "^0.0.x",
70
- "@stdlib/strided-base-reinterpret-complex64": "^0.0.x",
57
+ "@stdlib/array-complex128": "^0.1.0",
58
+ "@stdlib/array-complex64": "^0.1.0",
59
+ "@stdlib/array-float32": "^0.2.0",
60
+ "@stdlib/array-float64": "^0.2.0",
61
+ "@stdlib/array-int16": "^0.2.0",
62
+ "@stdlib/array-int32": "^0.2.0",
63
+ "@stdlib/array-int8": "^0.2.0",
64
+ "@stdlib/array-uint16": "^0.2.0",
65
+ "@stdlib/array-uint32": "^0.2.0",
66
+ "@stdlib/array-uint8": "^0.2.0",
67
+ "@stdlib/array-uint8c": "^0.2.0",
68
+ "@stdlib/assert-instance-of": "^0.2.0",
69
+ "@stdlib/math-base-special-pow": "^0.2.0",
70
+ "@stdlib/ndarray-base-zeros": "^0.1.0",
71
+ "@stdlib/ndarray-dtypes": "^0.2.0",
72
+ "@stdlib/ndarray-zeros": "^0.1.0",
73
+ "@stdlib/strided-base-reinterpret-complex128": "^0.2.0",
74
+ "@stdlib/strided-base-reinterpret-complex64": "^0.2.0",
71
75
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
72
76
  "istanbul": "^0.4.1",
73
- "tap-spec": "5.x.x"
77
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git",
78
+ "@stdlib/bench-harness": "^0.2.0",
79
+ "@stdlib/bench": "^0.3.1"
74
80
  },
75
81
  "engines": {
76
82
  "node": ">=0.10.0",
@@ -98,10 +104,11 @@
98
104
  "matrix",
99
105
  "fill",
100
106
  "filled",
101
- "zeros"
107
+ "zeros",
108
+ "numpy.zeros_like"
102
109
  ],
103
110
  "funding": {
104
- "type": "patreon",
105
- "url": "https://www.patreon.com/athan"
111
+ "type": "opencollective",
112
+ "url": "https://opencollective.com/stdlib"
106
113
  }
107
114
  }
package/docs/repl.txt DELETED
@@ -1,53 +0,0 @@
1
-
2
- {{alias}}( x[, options] )
3
- Returns a zero-filled ndarray having the same shape and data type as a
4
- provided input ndarray.
5
-
6
- The function infers the following attributes from the input array:
7
-
8
- - shape: array shape.
9
- - dtype: underlying array data type.
10
- - order: whether the array order is row-major (C-style) or column-major
11
- (Fortran-style).
12
-
13
- Parameters
14
- ----------
15
- x: ndarray
16
- Input array.
17
-
18
- options: Object (optional)
19
- Options.
20
-
21
- options.shape: ArrayLikeObject<integer>|integer (optional)
22
- Array shape. Overrides the input array's inferred shape.
23
-
24
- options.dtype: string (optional)
25
- Array data type. Overrides the input array's inferred data type.
26
-
27
- options.order: string (optional)
28
- Array order (either 'row-major' (C-style) or 'column-major' (Fortran-
29
- style)). Overrides the input array's inferred order.
30
-
31
- Returns
32
- -------
33
- out: ndarray
34
- Output array.
35
-
36
- Examples
37
- --------
38
- > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' )
39
- <ndarray>
40
- > var sh = x.shape
41
- [ 2, 2 ]
42
- > var dt = x.dtype
43
- 'float64'
44
- > var y = {{alias}}( x )
45
- <ndarray>
46
- > sh = y.shape
47
- [ 2, 2 ]
48
- > dt = y.dtype
49
- 'float64'
50
-
51
- See Also
52
- --------
53
-
@@ -1,167 +0,0 @@
1
- /*
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2022 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- import zeros = require( '@stdlib/ndarray-base-zeros' );
20
- import zerosLike = require( './index' );
21
-
22
-
23
- // TESTS //
24
-
25
- // The function returns an ndarray...
26
- {
27
- const sh = [ 2, 2 ];
28
- const ord = 'row-major';
29
-
30
- zerosLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray
31
- zerosLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray
32
- zerosLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray
33
- zerosLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray
34
- zerosLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray
35
- zerosLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray
36
- zerosLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray
37
- zerosLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray
38
- zerosLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray
39
- zerosLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray
40
- zerosLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray
41
- zerosLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray<number>
42
-
43
-
44
- zerosLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray
45
- zerosLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray
46
- zerosLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray
47
- zerosLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray
48
- zerosLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray
49
- zerosLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray
50
- zerosLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray
51
- zerosLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray
52
- zerosLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray
53
- zerosLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray
54
- zerosLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray
55
- zerosLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray<number>
56
-
57
-
58
- zerosLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray
59
- zerosLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray
60
- zerosLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray
61
- zerosLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray
62
- zerosLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray
63
- zerosLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray
64
- zerosLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray
65
- zerosLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray
66
- zerosLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray
67
- zerosLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray
68
- zerosLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray
69
- zerosLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray<number>
70
-
71
-
72
- zerosLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray
73
- zerosLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray
74
- zerosLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray
75
- zerosLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray
76
- zerosLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray
77
- zerosLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray
78
- zerosLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray
79
- zerosLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray
80
- zerosLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray
81
- zerosLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray
82
- zerosLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray
83
- zerosLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray<number>
84
-
85
-
86
- zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray
87
- zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray
88
- zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray
89
- zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray
90
- zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray
91
- zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray
92
- zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray
93
- zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray
94
- zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray
95
- zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray
96
- zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray
97
- zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray<number>
98
- }
99
-
100
- // The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type...
101
- {
102
- zerosLike( '10' ); // $ExpectError
103
- zerosLike( 10 ); // $ExpectError
104
- zerosLike( false ); // $ExpectError
105
- zerosLike( true ); // $ExpectError
106
- zerosLike( null ); // $ExpectError
107
- zerosLike( [] ); // $ExpectError
108
- zerosLike( {} ); // $ExpectError
109
- zerosLike( ( x: number ): number => x ); // $ExpectError
110
- }
111
-
112
- // The compiler throws an error if the function is provided a second argument is not an options object...
113
- {
114
- const x = zeros( 'generic', [ 2, 2 ], 'row-major' );
115
-
116
- zerosLike( x, '10' ); // $ExpectError
117
- zerosLike( x, 10 ); // $ExpectError
118
- zerosLike( x, false ); // $ExpectError
119
- zerosLike( x, true ); // $ExpectError
120
- zerosLike( x, [] ); // $ExpectError
121
- zerosLike( x, ( x: number ): number => x ); // $ExpectError
122
- }
123
-
124
- // The compiler throws an error if the function is provided a `dtype` option which is not a valid data type...
125
- {
126
- const x = zeros( 'generic', [ 2, 2 ], 'row-major' );
127
-
128
- zerosLike( x, { 'dtype': '10' } ); // $ExpectError
129
- zerosLike( x, { 'dtype': 10 } ); // $ExpectError
130
- zerosLike( x, { 'dtype': null } ); // $ExpectError
131
- zerosLike( x, { 'dtype': false } ); // $ExpectError
132
- zerosLike( x, { 'dtype': true } ); // $ExpectError
133
- zerosLike( x, { 'dtype': [] } ); // $ExpectError
134
- zerosLike( x, { 'dtype': {} } ); // $ExpectError
135
- zerosLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError
136
- }
137
-
138
- // The compiler throws an error if the function is provided an `order` option which is not a valid order...
139
- {
140
- const x = zeros( 'generic', [ 2, 2 ], 'row-major' );
141
-
142
- zerosLike( x, { 'order': '10' } ); // $ExpectError
143
- zerosLike( x, { 'order': 10 } ); // $ExpectError
144
- zerosLike( x, { 'order': false } ); // $ExpectError
145
- zerosLike( x, { 'order': true } ); // $ExpectError
146
- zerosLike( x, { 'order': [] } ); // $ExpectError
147
- zerosLike( x, { 'order': {} } ); // $ExpectError
148
- zerosLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError
149
- }
150
-
151
- // The compiler throws an error if the function is provided a `shape` option which is not a valid shape...
152
- {
153
- const x = zeros( 'generic', [ 2, 2 ], 'row-major' );
154
-
155
- zerosLike( x, { 'shape': '10' } ); // $ExpectError
156
- zerosLike( x, { 'shape': false } ); // $ExpectError
157
- zerosLike( x, { 'shape': true } ); // $ExpectError
158
- zerosLike( x, { 'shape': [ '5' ] } ); // $ExpectError
159
- zerosLike( x, { 'shape': {} } ); // $ExpectError
160
- zerosLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError
161
- }
162
-
163
- // The compiler throws an error if the function is provided an unsupported number of arguments...
164
- {
165
- zerosLike(); // $ExpectError
166
- zerosLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError
167
- }