Skip to content

Commit 01c5fe8

Browse files
committed
docs: update examples and docs to accommodate dtype instances
1 parent 2f38ba6 commit 01c5fe8

File tree

7 files changed

+331
-284
lines changed

7 files changed

+331
-284
lines changed

lib/node_modules/@stdlib/ndarray/zeros/README.md

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,49 +45,58 @@ var zeros = require( '@stdlib/ndarray/zeros' );
4545
Creates a zero-filled [ndarray][@stdlib/ndarray/ctor] having a specified shape and [data type][@stdlib/ndarray/dtypes].
4646

4747
```javascript
48+
var getShape = require( '@stdlib/ndarray/shape' );
49+
var getDType = require( '@stdlib/ndarray/dtype' );
50+
4851
var arr = zeros( [ 2, 2 ] );
49-
// returns <ndarray>
52+
// returns <ndarray>[ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]
5053

51-
var sh = arr.shape;
54+
var sh = getShape( arr );
5255
// returns [ 2, 2 ]
5356

54-
var dt = arr.dtype;
57+
var dt = String( getDType( arr ) );
5558
// returns 'float64'
5659
```
5760

58-
The specified output [ndarray][@stdlib/ndarray/ctor] `shape` may be either an array-like object or an integer value.
61+
The specified output [ndarray][@stdlib/ndarray/ctor] shape may be either an array-like object or an integer value.
5962

6063
```javascript
64+
var getShape = require( '@stdlib/ndarray/shape' );
65+
var getDType = require( '@stdlib/ndarray/dtype' );
66+
6167
var arr = zeros( 2 );
62-
// returns <ndarray>
68+
// returns <ndarray>[ 0.0, 0.0 ]
6369

64-
var sh = arr.shape;
70+
var sh = getShape( arr );
6571
// returns [ 2 ]
6672

67-
var dt = arr.dtype;
73+
var dt = String( getDType( arr ) );
6874
// returns 'float64'
6975
```
7076

71-
The function accepts the following `options`:
77+
The function accepts the following options:
7278

73-
- **dtype**: underlying [data type][@stdlib/ndarray/dtypes]. Must be a numeric [data type][@stdlib/ndarray/dtypes] or "generic". Default: `'float64'`.
79+
- **dtype**: underlying [data type][@stdlib/ndarray/dtypes]. Must be a numeric or "generic" [data type][@stdlib/ndarray/dtypes]. Default: `'float64'`.
7480
- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`.
75-
- **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`.
76-
- **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 ]`.
77-
- **readonly**: `boolean` indicating whether an array should be **read-only**. Default: `false`.
81+
- **mode**: specifies how to handle indices which exceed array dimensions (see [ndarray][@stdlib/ndarray/ctor]). Default: `'throw'`.
82+
- **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 ]`.
83+
- **readonly**: boolean indicating whether an array should be **read-only**. Default: `false`.
7884

7985
By default, the function returns an [ndarray][@stdlib/ndarray/ctor] having a [`float64`][@stdlib/ndarray/dtypes] data type. To specify an alternative [data type][@stdlib/ndarray/dtypes], provide a `dtype` option.
8086

8187
```javascript
88+
var getShape = require( '@stdlib/ndarray/shape' );
89+
var getDType = require( '@stdlib/ndarray/dtype' );
90+
8291
var arr = zeros( [ 2, 2 ], {
8392
'dtype': 'float32'
8493
});
85-
// returns <ndarray>
94+
// returns <ndarray>[ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]
8695

87-
var sh = arr.shape;
96+
var sh = getShape( arr );
8897
// returns [ 2, 2 ]
8998

90-
var dt = arr.dtype;
99+
var dt = String( getDType( arr ) );
91100
// returns 'float32'
92101
```
93102

@@ -113,10 +122,11 @@ var dt = arr.dtype;
113122

114123
```javascript
115124
var dtypes = require( '@stdlib/ndarray/dtypes' );
125+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
116126
var zeros = require( '@stdlib/ndarray/zeros' );
117127

118128
// Get a list of data types:
119-
var dt = dtypes( 'numeric' );
129+
var dt = dtypes( 'integer_and_generic' );
120130

121131
// Generate zero-filled arrays...
122132
var arr;
@@ -125,7 +135,7 @@ for ( i = 0; i < dt.length; i++ ) {
125135
arr = zeros( [ 2, 2 ], {
126136
'dtype': dt[ i ]
127137
});
128-
console.log( arr.data );
138+
console.log( ndarray2array( arr ) );
129139
}
130140
```
131141

lib/node_modules/@stdlib/ndarray/zeros/docs/repl.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
options: Object (optional)
1111
Options.
1212

13-
options.dtype: string (optional)
14-
Underlying data type. Must be a numeric data type or "generic". Default:
13+
options.dtype: string|DataType (optional)
14+
Underlying data type. Must be a numeric or "generic" data type. Default:
1515
'float64'.
1616

1717
options.order: string (optional)
@@ -52,11 +52,7 @@
5252
Examples
5353
--------
5454
> var arr = {{alias}}( [ 2, 2 ] )
55-
<ndarray>
56-
> var sh = arr.shape
57-
[ 2, 2 ]
58-
> var dt = arr.dtype
59-
'float64'
55+
<ndarray>[ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]
6056

6157
See Also
6258
--------

0 commit comments

Comments
 (0)