Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2c41a9

Browse filesBrowse files
committed
wip test case for geomean numerics
1 parent ac3ddc3 commit e2c41a9
Copy full SHA for e2c41a9

File tree

1 file changed

+17
-0
lines changed
Filter options

1 file changed

+17
-0
lines changed

‎test/jasmine/tests/calcdata_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/calcdata_test.js
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,23 @@ describe('calculated data and points', function() {
11541154
checkAggregatedValue(baseMock, expectedAgg, false, done);
11551155
});
11561156

1157+
it('takes the geomean of all values per category across traces of type ' + trace.type, function(done) {
1158+
var type = trace.type;
1159+
var data = [7, 2, 3];
1160+
var data2 = [5, 4, 2];
1161+
var baseMock = { data: [makeData(type, axName, cat, data), makeData(type, axName, cat, data2)], layout: {}};
1162+
baseMock.layout[axName] = { type: 'category', categoryorder: 'geomean ascending'};
1163+
1164+
var expectedAgg = [['a', Math.sqrt(data[0] * data2[0])], ['b', Math.sqrt(data[1] * data2[1])], ['c', Math.sqrt(data[2] * data2[2])]];
1165+
// TODO: how to actually calc these? what do these even mean?
1166+
if(type === 'histogram') expectedAgg = [['a', 2], ['b', 1], ['c', 1]];
1167+
if(type === 'histogram2d') expectedAgg = [['a', 2 / 3], ['b', 1 / 3], ['c', 1 / 3]];
1168+
if(type === 'contour' || type === 'heatmap') expectedAgg = [['a', expectedAgg[0][1] / 3], ['b', expectedAgg[1][1] / 3], ['c', expectedAgg[2][1] / 3]];
1169+
if(type === 'histogram2dcontour') expectedAgg = [['a', 2 / 4], ['b', 1 / 4], ['c', 1 / 4]];
1170+
1171+
checkAggregatedValue(baseMock, expectedAgg, false, done);
1172+
});
1173+
11571174
it('takes the median of all values per category across traces of type ' + trace.type, function(done) {
11581175
var type = trace.type;
11591176
var data = [7, 2, 3];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.