Skip to content

Commit 59557c1

Browse files
committed
revise dtypes
1 parent 8c4202b commit 59557c1

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

src/lib/array.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ exports.ensureArray = function(out, n) {
5252
};
5353

5454
var typedArrays = {
55-
c1: typeof Uint8ClampedArray === 'undefined' ? undefined :
56-
Uint8ClampedArray, // not supported in numpy?
55+
u1c: typeof Uint8ClampedArray === 'undefined' ? undefined :
56+
Uint8ClampedArray, // not supported in numpy?
5757

5858
i1: typeof Int8Array === 'undefined' ? undefined :
5959
Int8Array,
@@ -89,6 +89,16 @@ var typedArrays = {
8989
*/
9090
};
9191

92+
typedArrays.uint8c = typedArrays.u1c;
93+
typedArrays.uint8 = typedArrays.u1;
94+
typedArrays.int8 = typedArrays.i1;
95+
typedArrays.uint16 = typedArrays.u2;
96+
typedArrays.int16 = typedArrays.i2;
97+
typedArrays.uint32 = typedArrays.u4;
98+
typedArrays.int32 = typedArrays.i4;
99+
typedArrays.float32 = typedArrays.f4;
100+
typedArrays.float64 = typedArrays.f8;
101+
92102
function isArrayBuffer(a) {
93103
return a.constructor === ArrayBuffer;
94104
}

src/lib/coerce.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,21 @@ exports.valObjectMeta = {
2525
'(1) a regular {array} object',
2626
'(2) a typed array (e.g. Float32Array)',
2727
'(3) an object with keys dtype, bdata, and optionally shape.',
28-
'In this 3rd form, dtype is one of *i1*, *u1*, *c1*,',
29-
'*i2*, *u2*, *i4*, *u4*, *f4*, or *f8*.',
28+
'In this 3rd form, dtype is one of',
29+
'*f8*, *f4*.',
30+
'*i4*, *u4*,',
31+
'*i2*, *u2*,',
32+
'*i1*, *u1* or *u1c* for Uint8ClampedArray.',
33+
'In addition to shorthand `dtype` above one could also use the following forms:',
34+
'*float64*, *float32*,',
35+
'*int32*, *uint32*,',
36+
'*int16*, *uint16*,',
37+
'*int8*, *uint8* or *uint8c* for Uint8ClampedArray.',
3038
'`bdata` is either a base64-encoded string or the ArrayBuffer of',
3139
'an integer or float typed array.',
3240
'For either multi-dimensional arrays you must also',
3341
'provide its dimensions separated by comma via `shape`.',
34-
'For exmaple using `dtype`: *f4* and `shape`: *5,100* you can',
42+
'For example using `dtype`: *f4* and `shape`: *5,100* you can',
3543
'declare a 2-D array that has 5 rows and 100 columns',
3644
'containing float32 values i.e. 4 bits per value.',
3745
'`shape` is optional for one dimensional arrays.'

test/jasmine/tests/toimage_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ describe('Plotly.toImage', function() {
458458
z: {bdata: z, dtype: 'i1'},
459459
marker: {
460460
color: {bdata: c, dtype: 'u1'},
461-
size: {bdata: s, dtype: 'c1'}
461+
size: {bdata: s, dtype: 'u1c'}
462462
}
463463
}])
464464
.then(function(gd) {
@@ -495,7 +495,7 @@ describe('Plotly.toImage', function() {
495495
}
496496

497497
expect(trace.marker.size.bdata).toEqual('ADx48A==');
498-
expect(trace.marker.size.dtype).toEqual('c1');
498+
expect(trace.marker.size.dtype).toEqual('u1c');
499499
expect(trace.marker.size.shape).toEqual('4');
500500

501501
expect(trace.marker.color.bdata).toEqual('ADx48A==');

test/plot-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@
479479
"requiredOpts": []
480480
},
481481
"data_array": {
482-
"description": "An {array} of data. The value must represent an {array} or it will be ignored, but this array can be provided in several forms: (1) a regular {array} object (2) a typed array (e.g. Float32Array) (3) an object with keys dtype, bdata, and optionally shape. In this 3rd form, dtype is one of *i1*, *u1*, *c1*, *i2*, *u2*, *i4*, *u4*, *f4*, or *f8*. `bdata` is either a base64-encoded string or the ArrayBuffer of an integer or float typed array. For either multi-dimensional arrays you must also provide its dimensions separated by comma via `shape`. For exmaple using `dtype`: *f4* and `shape`: *5,100* you can declare a 2-D array that has 5 rows and 100 columns containing float32 values i.e. 4 bits per value. `shape` is optional for one dimensional arrays.",
482+
"description": "An {array} of data. The value must represent an {array} or it will be ignored, but this array can be provided in several forms: (1) a regular {array} object (2) a typed array (e.g. Float32Array) (3) an object with keys dtype, bdata, and optionally shape. In this 3rd form, dtype is one of *f8*, *f4*. *i4*, *u4*, *i2*, *u2*, *i1*, *u1* or *u1c* for Uint8ClampedArray. In addition to shorthand `dtype` above one could also use the following forms: *float64*, *float32*, *int32*, *uint32*, *int16*, *uint16*, *int8*, *uint8* or *uint8c* for Uint8ClampedArray. `bdata` is either a base64-encoded string or the ArrayBuffer of an integer or float typed array. For either multi-dimensional arrays you must also provide its dimensions separated by comma via `shape`. For example using `dtype`: *f4* and `shape`: *5,100* you can declare a 2-D array that has 5 rows and 100 columns containing float32 values i.e. 4 bits per value. `shape` is optional for one dimensional arrays.",
483483
"otherOpts": [
484484
"dflt"
485485
],

0 commit comments

Comments
 (0)