Skip to content

Commit

Permalink
simplify get direction function in streamtube calc and improve jasmin…
Browse files Browse the repository at this point in the history
…e test for random input
  • Loading branch information
archmoj committed Oct 18, 2019
1 parent 608dc1a commit 4af4984
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/traces/streamtube/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports = function calc(gd, trace) {

var getArray = function(c) { return c === 'x' ? x : c === 'y' ? y : z; };
var getVals = function(c) { return c === 'x' ? Xs : c === 'y' ? Ys : Zs; };
var getDir = function(c) { return (+(c[len - 1] - c[0])) * 2 + 1; };
var getDir = function(c) { return (c[len - 1] < c[0]) ? -1 : 1; };

var arrK = getArray(gridFill[1]);
var arrJ = getArray(gridFill[3]);
Expand Down
22 changes: 11 additions & 11 deletions test/jasmine/tests/streamtube_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,13 @@ describe('Test streamtube interactions', function() {
var v = [];
var w = [];

for(var i = 0; i < 3; i++) {
for(var j = i; j < 4; j++) {
for(var k = j; k < 5; k++) {
x.push(i);
y.push(j);
z.push(k);
u.push(1);
v.push(1);
w.push(1);
}
}
for(var n = 0; n < 1000; n++) {
x.push((10 * Math.random()) | 0);
y.push((10 * Math.random()) | 0);
z.push((10 * Math.random()) | 0);
u.push(1);
v.push(1);
w.push(1);
}

var fig = {
Expand All @@ -338,11 +334,15 @@ describe('Test streamtube interactions', function() {
expect(exp.cellsLength).toBe(objs[0].cells.length, 'cells length - ' + msg);
}

spyOn(Lib, 'warn');

Plotly.plot(gd, fig).then(function() {
_assert('arbitrary coordinates', {
positionsLength: 0,
cellsLength: 0
});
}).then(function() {
expect(Lib.warn).toHaveBeenCalledWith('Encountered arbitrary coordinates! Unable to input data grid.');
})
.catch(failTest)
.then(done);
Expand Down

0 comments on commit 4af4984

Please sign in to comment.