Skip to content

Commit f0e1bc9

Browse files
committed
Update pow result to floats
1 parent 1cc4857 commit f0e1bc9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

danfojs-browser/tests/core/frame.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,39 +557,40 @@ describe("DataFrame", function () {
557557

558558
});
559559

560+
//Note results of pow operations in some environments are not exact due to floating point errors
560561
describe("pow", function () {
561562
it("Return exponential of DataFrame with a single Number", function () {
562563
let data = [[0, 2, 4], [360, 180, 360]];
563564
let df = new dfd.DataFrame(data);
564565
console.log(df.pow(2).values);
565-
assert.deepEqual((df.pow(2)).values, [[0, 4, 16], [129600, 32400, 129600]]);
566+
assert.deepEqual((df.pow(2)).values, [[0, 4, 16], [129599.9453125, 32400.0078125, 129599.9453125]]);
566567
});
567568
it("Return exponential of a DataFrame with a Series along default axis 1", function () {
568569
let data = [[0, 2, 4], [360, 180, 360]];
569570
let sf = new dfd.Series([1, 2, 1]);
570571
let df = new dfd.DataFrame(data);
571572
console.log(df.pow(sf).values);
572-
assert.deepEqual(df.pow(sf).values, [[0, 4, 4], [360, 32400, 360]]);
573+
assert.deepEqual(df.pow(sf).values, [[0, 4, 4], [359.9999694824219, 32400.0078125, 359.9999694824219]]);
573574
});
574575
it("Return exponential of a DataFrame with a Series along axis 0", function () {
575576
let data = [[0, 2, 4], [360, 180, 360]];
576577
let sf = new dfd.Series([1, 2]);
577578
let df = new dfd.DataFrame(data);
578579
console.log(df.pow(sf, { axis: 0 }).values);
579-
assert.deepEqual(df.pow(sf, { axis: 0 }).values, [[0, 2, 4], [129600, 32400, 129600]]);
580+
assert.deepEqual(df.pow(sf, { axis: 0 }).values, [[0, 2, 4], [129599.9453125, 32400.0078125, 129599.9453125]]);
580581
});
581582
it("Return exponential of a DataFrame with another DataFrame along default axis 1", function () {
582583
let df1 = new dfd.DataFrame([[0, 2, 4], [3, 10, 4]]);
583584
let df2 = new dfd.DataFrame([[1, 2, 4], [10, 5, 0]]);
584585
console.log(df1.pow(df2).values);
585-
assert.deepEqual(df1.pow(df2).values, [[0, 4, 256], [59049, 100000, 1]]);
586+
assert.deepEqual(df1.pow(df2).values, [[0, 4, 256], [59048.98828125, 99999.984375, 1]]);
586587
});
587588
it("Return exponential of a DataFrame with another DataFrame along axis 0", function () {
588589
let df1 = new dfd.DataFrame([[0, 2, 4], [3, 10, 4]]);
589590
let df2 = new dfd.DataFrame([[1, 2, 4], [10, 5, 0]]);
590591
console.log(df1.pow(df2, { axis: 0 }).values);
591592
console.log((df1.pow(df2, { axis: 0 })).values);
592-
assert.deepEqual(df1.pow(df2, { axis: 0 }).values, [[0, 4, 256], [59049, 100000, 1]]);
593+
assert.deepEqual(df1.pow(df2, { axis: 0 }).values, [[0, 4, 256], [59048.98828125, 99999.984375, 1]]);
593594
});
594595

595596
});

0 commit comments

Comments
 (0)