time-to-botec/squiggle/node_modules/jstat/test/vector/cumprod-test.js
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

52 lines
1.4 KiB
JavaScript

var vows = require('vows');
var assert = require('assert');
var suite = vows.describe('jStat.cumprod');
require('../env.js');
suite.addBatch({
'cumprod': {
'topic': function() {
return jStat;
},
'return basic cumprod': function(jStat) {
assert.deepEqual(jStat.cumprod([1, 2, 3]), [1, 2, 6]);
},
'cumprod from instance': function(jStat) {
assert.deepEqual(jStat([1, 2, 3]).cumprod(), [1, 2, 6]);
},
'cumprod matrix cols': function(jStat) {
assert.deepEqual(jStat([[1, 2], [3, 4]]).cumprod(), [[1, 3], [2, 8]]);
},
'cumprod matrix rows': function(jStat) {
assert.deepEqual(jStat([[1, 2], [3, 4]]).cumprod(true), [[1, 2], [3, 12]]);
}
},
'#cumprod vector': {
'topic': function() {
jStat([1, 2, 3]).cumprod(this.callback);
},
'cumprod callback': function(val, stat) {
assert.deepEqual(val, [1, 2, 6]);
}
},
'#cumprod matrix cols': {
'topic': function() {
jStat([[1, 2], [3, 4]]).cumprod(this.callback);
},
'cumprod matrix cols callback': function(val, stat) {
assert.deepEqual(val, [[1, 3], [2, 8]]);
}
},
'#cumprod matrix rows': {
'topic': function() {
jStat([[1, 2], [3, 4]]).cumprod(true, this.callback);
},
'cumprod matrix rows callback': function(val, stat) {
assert.deepEqual(val, [[1, 2], [3, 12]]);
}
}
});
suite.export(module);