Skip to content

Commit 832af54

Browse files
committed
allow 3d arrays used e.g. by image trace
1 parent 0f2ef23 commit 832af54

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/lib/array.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,28 +114,23 @@ exports.decodeTypedArraySpec = function(vIn) {
114114
('' + v.shape).split(',');
115115

116116
shape.reverse(); // i.e. to match numpy order
117-
var ndims = shape.length;
117+
var ndim = shape.length;
118118

119119
var nj, j;
120120
var ni = +shape[0];
121121

122122
var rowBytes = BYTES_PER_ELEMENT * ni;
123123
var pos = 0;
124124

125-
if(ndims === 1) {
125+
if(ndim === 1) {
126126
out = new T(buffer);
127-
} else if(ndims === 2) {
127+
} else if(ndim === 2) {
128128
nj = +shape[1];
129129
for(j = 0; j < nj; j++) {
130130
out[j] = new T(buffer, pos, ni);
131131
pos += rowBytes;
132132
}
133-
/*
134-
135-
// 3d arrays are not supported in traces e.g. volume & isosurface
136-
// once supported we could uncomment this part
137-
138-
} else if(ndims === 3) {
133+
} else if(ndim === 3) {
139134
nj = +shape[1];
140135
var nk = +shape[2];
141136
for(var k = 0; k < nk; k++) {
@@ -145,9 +140,8 @@ exports.decodeTypedArraySpec = function(vIn) {
145140
pos += rowBytes;
146141
}
147142
}
148-
*/
149143
} else {
150-
throw new Error('Error in shape: "' + v.shape + '"');
144+
throw new Error('ndim: ' + ndim + 'is not supported with the shape:"' + v.shape + '"');
151145
}
152146

153147
// attach bdata, dtype & shape to array for json export

0 commit comments

Comments
 (0)