Skip to content

Commit

Permalink
wip test case for geomean numerics
Browse files Browse the repository at this point in the history
  • Loading branch information
acxz committed Jun 13, 2022
1 parent ac3ddc3 commit e2c41a9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/jasmine/tests/calcdata_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,23 @@ describe('calculated data and points', function() {
checkAggregatedValue(baseMock, expectedAgg, false, done);
});

it('takes the geomean of all values per category across traces of type ' + trace.type, function(done) {
var type = trace.type;
var data = [7, 2, 3];
var data2 = [5, 4, 2];
var baseMock = { data: [makeData(type, axName, cat, data), makeData(type, axName, cat, data2)], layout: {}};
baseMock.layout[axName] = { type: 'category', categoryorder: 'geomean ascending'};

var expectedAgg = [['a', Math.sqrt(data[0] * data2[0])], ['b', Math.sqrt(data[1] * data2[1])], ['c', Math.sqrt(data[2] * data2[2])]];
// TODO: how to actually calc these? what do these even mean?
if(type === 'histogram') expectedAgg = [['a', 2], ['b', 1], ['c', 1]];
if(type === 'histogram2d') expectedAgg = [['a', 2 / 3], ['b', 1 / 3], ['c', 1 / 3]];
if(type === 'contour' || type === 'heatmap') expectedAgg = [['a', expectedAgg[0][1] / 3], ['b', expectedAgg[1][1] / 3], ['c', expectedAgg[2][1] / 3]];
if(type === 'histogram2dcontour') expectedAgg = [['a', 2 / 4], ['b', 1 / 4], ['c', 1 / 4]];

checkAggregatedValue(baseMock, expectedAgg, false, done);
});

it('takes the median of all values per category across traces of type ' + trace.type, function(done) {
var type = trace.type;
var data = [7, 2, 3];
Expand Down

0 comments on commit e2c41a9

Please sign in to comment.