Skip to content

Commit 4c23da8

Browse files
committed
Auto-generated commit
1 parent 0e2f033 commit 4c23da8

File tree

17 files changed

+73
-120
lines changed

17 files changed

+73
-120
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,12 @@ A total of 37 issues were closed in this release:
675675

676676
<details>
677677

678+
- [`322b8cb`](https://github.com/stdlib-js/stdlib/commit/322b8cb870769d9198ddbcd0b89610b185ab57ff) - **build:** ensure dtypes are strings _(by Athan Reines)_
679+
- [`387beea`](https://github.com/stdlib-js/stdlib/commit/387beea5c84c7bd4f0aab41ec35e49819275c9b0) - **build:** ensure dtypes are strings _(by Athan Reines)_
680+
- [`2a887b7`](https://github.com/stdlib-js/stdlib/commit/2a887b7eb76a7f0ecc48133049868395b90ff196) - **refactor:** support data type instances _(by Athan Reines)_
681+
- [`760719b`](https://github.com/stdlib-js/stdlib/commit/760719b492247734f2778d4ace525d6719b2d202) - **refactor:** normalize a data type to a string _(by Athan Reines)_
682+
- [`a52bc78`](https://github.com/stdlib-js/stdlib/commit/a52bc786e790aa242a563cdaefb58107b6cd2d9b) - **refactor:** normalize a provided data type to a string _(by Athan Reines)_
683+
- [`982208c`](https://github.com/stdlib-js/stdlib/commit/982208cf3c840a5f3ff23378056cd7843dc1e173) - **docs:** update dtype type _(by Athan Reines)_
678684
- [`6c43167`](https://github.com/stdlib-js/stdlib/commit/6c4316733d615b06d301eec89c377838a6b56dd8) - **fix:** resolve normalized data type _(by Athan Reines)_
679685
- [`697b9ed`](https://github.com/stdlib-js/stdlib/commit/697b9edd6f85e39a03bed4f142814238bb3cdce8) - **docs:** update examples and docs to accommodate data type instances _(by Athan Reines)_
680686
- [`452cc00`](https://github.com/stdlib-js/stdlib/commit/452cc003a69938f9cdce6ed45219f41673af1c1f) - **docs:** update example _(by Athan Reines)_

base/binary-tiling-block-size/docs/repl.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
Parameters
66
----------
7-
dtypeX: string
7+
dtypeX: string|DataType
88
First input array data type.
99

10-
dtypeY: string
10+
dtypeY: string|DataType
1111
Second input array data type.
1212

13-
dtypeZ: string
13+
dtypeZ: string|DataType
1414
Output array data type.
1515

1616
Returns

base/binary-tiling-block-size/docs/types/index.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
// TypeScript Version: 4.1
2020

21+
/// <reference types="@stdlib/types"/>
22+
23+
import { DataType } from '@stdlib/types/ndarray';
24+
2125
/**
2226
* Returns a loop block size for multi-dimensional array tiled loops.
2327
*
@@ -30,7 +34,7 @@
3034
* var bsize = binaryBlockSize( 'float64', 'float64', 'float64' );
3135
* // returns <number>
3236
*/
33-
declare function binaryBlockSize( dtypeX: string, dtypeY: string, dtypeZ: string ): number;
37+
declare function binaryBlockSize( dtypeX: DataType, dtypeY: DataType, dtypeZ: DataType ): number;
3438

3539

3640
// EXPORTS //

base/binary-tiling-block-size/docs/types/test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import binaryBlockSize = require( './index' );
2727
binaryBlockSize( 'generic', 'generic', 'generic' ); // $ExpectType number
2828
}
2929

30-
// The compiler throws an error if the function is provided a first argument which is not a string...
30+
// The compiler throws an error if the function is provided a first argument which is not a valid data type...
3131
{
3232
binaryBlockSize( 123, 'float64', 'float64' ); // $ExpectError
3333
binaryBlockSize( true, 'float64', 'float64' ); // $ExpectError
@@ -38,7 +38,7 @@ import binaryBlockSize = require( './index' );
3838
binaryBlockSize( ( x: number ): number => x, 'float64', 'float64' ); // $ExpectError
3939
}
4040

41-
// The compiler throws an error if the function is provided a second argument which is not a string...
41+
// The compiler throws an error if the function is provided a second argument which is not a valid data type...
4242
{
4343
binaryBlockSize( 'int32', 123, 'int32' ); // $ExpectError
4444
binaryBlockSize( 'int32', true, 'int32' ); // $ExpectError
@@ -49,7 +49,7 @@ import binaryBlockSize = require( './index' );
4949
binaryBlockSize( 'int32', ( x: number ): number => x, 'int32' ); // $ExpectError
5050
}
5151

52-
// The compiler throws an error if the function is provided a third argument which is not a string...
52+
// The compiler throws an error if the function is provided a third argument which is not a valid data type...
5353
{
5454
binaryBlockSize( 'int32', 'int32', 123 ); // $ExpectError
5555
binaryBlockSize( 'int32', 'int32', true ); // $ExpectError

base/binary-tiling-block-size/lib/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ var defaults = require( './defaults.js' );
2929
/**
3030
* Returns a loop block size for multi-dimensional array tiled loops.
3131
*
32-
* @param {string} dtypeX - first input array data type
33-
* @param {string} dtypeY - second input array data type
34-
* @param {string} dtypeZ - output array data type
32+
* @param {*} dtypeX - first input array data type
33+
* @param {*} dtypeY - second input array data type
34+
* @param {*} dtypeZ - output array data type
3535
* @returns {integer} block size (in units of elements)
3636
*
3737
* @example

base/broadcast-scalar/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# broadcastScalar
2222

23-
> Broadcast a scalar value to an [`ndarray`][@stdlib/ndarray/base/ctor] having a specified shape.
23+
> Broadcast a scalar value to an [ndarray][@stdlib/ndarray/base/ctor] having a specified shape.
2424
2525
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
2626

@@ -42,7 +42,7 @@ var broadcastScalar = require( '@stdlib/ndarray/base/broadcast-scalar' );
4242

4343
#### broadcastScalar( value, dtype, shape, order )
4444

45-
Broadcasts a scalar value to an [`ndarray`][@stdlib/ndarray/base/ctor] having a specified shape and [data type][@stdlib/ndarray/dtypes].
45+
Broadcasts a scalar value to an [ndarray][@stdlib/ndarray/base/ctor] having a specified shape and [data type][@stdlib/ndarray/dtypes].
4646

4747
```javascript
4848
var getShape = require( '@stdlib/ndarray/shape' );
@@ -71,9 +71,9 @@ var v = x.get( 0, 0 );
7171

7272
## Notes
7373

74-
- If `value` is a number and [`dtype`][@stdlib/ndarray/dtypes] is a complex [data type][@stdlib/ndarray/dtypes], the function returns an [`ndarray`][@stdlib/ndarray/base/ctor] containing a complex number whose real component equals the provided scalar `value` and whose imaginary component is zero.
74+
- If `value` is a number and [`dtype`][@stdlib/ndarray/dtypes] is a complex [data type][@stdlib/ndarray/dtypes], the function returns an [ndarray][@stdlib/ndarray/base/ctor] containing a complex number whose real component equals the provided scalar `value` and whose imaginary component is zero.
7575
- The returned [ndarray][@stdlib/ndarray/base/ctor] is a view on an [ndarray][@stdlib/ndarray/base/ctor] data buffer containing a single element. The view is **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to the view may affect multiple elements. If you need to write to the returned [ndarray][@stdlib/ndarray/base/ctor], copy the [ndarray][@stdlib/ndarray/base/ctor] **before** performing operations which may mutate elements.
76-
- The returned [ndarray][@stdlib/ndarray/base/ctor] is a "base" [ndarray][@stdlib/ndarray/base/ctor], and, thus, the returned [ndarray][@stdlib/ndarray/base/ctor] does not perform bounds checking or afford any of the guarantees of the non-base [ndarray][@stdlib/ndarray/ctor] constructor. The primary intent of this function is to broadcast a scalar value as an [`ndarray`][@stdlib/ndarray/base/ctor] within internal implementations and to do so with minimal overhead.
76+
- The returned [ndarray][@stdlib/ndarray/base/ctor] is a "base" [ndarray][@stdlib/ndarray/base/ctor], and, thus, the returned [ndarray][@stdlib/ndarray/base/ctor] does not perform bounds checking or afford any of the guarantees of the non-base [ndarray][@stdlib/ndarray/ctor] constructor. The primary intent of this function is to broadcast a scalar value as an [ndarray][@stdlib/ndarray/base/ctor] within internal implementations and to do so with minimal overhead.
7777

7878
</section>
7979

base/broadcast-scalar/docs/repl.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
<ndarray>
4444
> var sh = {{alias:@stdlib/ndarray/shape}}( x )
4545
[ 2, 2 ]
46-
> var dt = {{alias:@stdlib/ndarray/dtype}}( x )
47-
'float64'
4846
> var v = x.get( 0, 1 )
4947
1.0
5048

base/broadcast-scalar/docs/types/index.d.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { ndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, in
4242
* var sh = getShape( x );
4343
* // returns [ 2, 2 ]
4444
*
45-
* var dt = getDType( x );
45+
* var dt = String( getDType( x ) );
4646
* // returns 'float64'
4747
*
4848
* var v = x.get( 0, 1 );
@@ -69,7 +69,7 @@ declare function broadcastScalar( value: number, dtype: 'float64', shape: Shape,
6969
* var sh = getShape( x );
7070
* // returns [ 2, 2 ]
7171
*
72-
* var dt = getDType( x );
72+
* var dt = String( getDType( x ) );
7373
* // returns 'float32'
7474
*
7575
* var v = x.get( 0, 1 );
@@ -103,7 +103,7 @@ declare function broadcastScalar( value: number, dtype: 'float32', shape: Shape,
103103
* var sh = getShape( x );
104104
* // returns [ 2, 2 ]
105105
*
106-
* var dt = getDType( x );
106+
* var dt = String( getDType( x ) );
107107
* // returns 'complex128'
108108
*
109109
* var v = x.get( 0, 1 );
@@ -139,7 +139,7 @@ declare function broadcastScalar( value: number | ComplexLike, dtype: 'complex12
139139
* var sh = getShape( x );
140140
* // returns [ 2, 2 ]
141141
*
142-
* var dt = getDType( x );
142+
* var dt = String( getDType( x ) );
143143
* // returns 'complex64'
144144
*
145145
* var v = x.get( 0, 1 );
@@ -172,7 +172,7 @@ declare function broadcastScalar( value: number | ComplexLike, dtype: 'complex64
172172
* var sh = getShape( x );
173173
* // returns [ 2, 2 ]
174174
*
175-
* var dt = getDType( x );
175+
* var dt = String( getDType( x ) );
176176
* // returns 'int32'
177177
*
178178
* var v = x.get( 0, 1 );
@@ -199,7 +199,7 @@ declare function broadcastScalar( value: number, dtype: 'int32', shape: Shape, o
199199
* var sh = getShape( x );
200200
* // returns [ 2, 2 ]
201201
*
202-
* var dt = getDType( x );
202+
* var dt = String( getDType( x ) );
203203
* // returns 'int16'
204204
*
205205
* var v = x.get( 0, 1 );
@@ -226,7 +226,7 @@ declare function broadcastScalar( value: number, dtype: 'int16', shape: Shape, o
226226
* var sh = getShape( x );
227227
* // returns [ 2, 2 ]
228228
*
229-
* var dt = getDType( x );
229+
* var dt = String( getDType( x ) );
230230
* // returns 'int8'
231231
*
232232
* var v = x.get( 0, 1 );
@@ -253,7 +253,7 @@ declare function broadcastScalar( value: number, dtype: 'int8', shape: Shape, or
253253
* var sh = getShape( x );
254254
* // returns [ 2, 2 ]
255255
*
256-
* var dt = getDType( x );
256+
* var dt = String( getDType( x ) );
257257
* // returns 'uint32'
258258
*
259259
* var v = x.get( 0, 1 );
@@ -280,7 +280,7 @@ declare function broadcastScalar( value: number, dtype: 'uint32', shape: Shape,
280280
* var sh = getShape( x );
281281
* // returns [ 2, 2 ]
282282
*
283-
* var dt = getDType( x );
283+
* var dt = String( getDType( x ) );
284284
* // returns 'uint16'
285285
*
286286
* var v = x.get( 0, 1 );
@@ -307,7 +307,7 @@ declare function broadcastScalar( value: number, dtype: 'uint16', shape: Shape,
307307
* var sh = getShape( x );
308308
* // returns [ 2, 2 ]
309309
*
310-
* var dt = getDType( x );
310+
* var dt = String( getDType( x ) );
311311
* // returns 'uint8'
312312
*
313313
* var v = x.get( 0, 1 );
@@ -334,7 +334,7 @@ declare function broadcastScalar( value: number, dtype: 'uint8', shape: Shape, o
334334
* var sh = getShape( x );
335335
* // returns [ 2, 2 ]
336336
*
337-
* var dt = getDType( x );
337+
* var dt = String( getDType( x ) );
338338
* // returns 'uint8c'
339339
*
340340
* var v = x.get( 0, 1 );
@@ -361,7 +361,7 @@ declare function broadcastScalar( value: number, dtype: 'uint8c', shape: Shape,
361361
* var sh = getShape( x );
362362
* // returns [ 2, 2 ]
363363
*
364-
* var dt = getDType( x );
364+
* var dt = String( getDType( x ) );
365365
* // returns 'generic'
366366
*
367367
* var v = x.get( 0, 1 );

base/broadcast-scalar/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* var sh = getShape( x );
3535
* // returns [ 2, 2 ]
3636
*
37-
* var dt = getDType( x );
37+
* var dt = String( getDType( x ) );
3838
* // returns 'float64'
3939
*
4040
* var v = x.get( 0, 1 );

base/broadcast-scalar/lib/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var setter = require( '@stdlib/array/base/setter' );
2828
var zeros = require( '@stdlib/array/base/zeros' );
2929
var buffer = require( './../../../base/buffer' );
3030
var ndarray = require( './../../../base/ctor' );
31+
var resolveStr = require( './../../../base/dtype-resolve-str' );
3132
var format = require( '@stdlib/string/format' );
3233

3334

@@ -53,7 +54,7 @@ var format = require( '@stdlib/string/format' );
5354
* var sh = getShape( x );
5455
* // returns [ 2, 2 ]
5556
*
56-
* var dt = getDType( x );
57+
* var dt = String( getDType( x ) );
5758
* // returns 'float64'
5859
*
5960
* var v = x.get( 0, 1 );
@@ -68,6 +69,7 @@ function broadcastScalar( value, dtype, shape, order ) {
6869
if ( buf === null ) {
6970
throw new TypeError( format( 'invalid argument. Second argument must be a recognized data type. Value: `%s`.', dtype ) );
7071
}
72+
dtype = resolveStr( dtype );
7173
if ( isComplexDataType( dtype ) && isNumber( value ) ) {
7274
value = [ value, 0.0 ]; // note: we're assuming that the ComplexXXArray setter accepts an array of interleaved real and imaginary components
7375
}

0 commit comments

Comments
 (0)