diff --git a/src/danfojs-base/shared/errors.ts b/src/danfojs-base/shared/errors.ts index cdd256d6..a433ab56 100644 --- a/src/danfojs-base/shared/errors.ts +++ b/src/danfojs-base/shared/errors.ts @@ -52,7 +52,7 @@ class ErrorThrower { } throwColumnLengthError = (ndframe: NDframe | DataFrame, arrLen: number): void => { - const msg = `ParamError: Column data length mismatch. You provided data with length ${arrLen} but Ndframe has column of length ${ndframe.shape[1]}` + const msg = `ParamError: Column data length mismatch. You provided data with length ${arrLen} but Ndframe has column of length ${ndframe.shape[0]}` throw new Error(msg) } diff --git a/src/danfojs-browser/tests/core/frame.test.js b/src/danfojs-browser/tests/core/frame.test.js index 9df80e54..593c4e13 100644 --- a/src/danfojs-browser/tests/core/frame.test.js +++ b/src/danfojs-browser/tests/core/frame.test.js @@ -123,11 +123,11 @@ describe("DataFrame", function () { const data = { alpha: [ "A", "B", "C", "D" ], count: [ 1, 2, 3, 4 ], sum: [ 20.3, 30.456, 40.90, 90.1 ] }; const df = new dfd.DataFrame(data); - assert.throws(function () { - df.addColumn("new_column", new dfd.Series([ "a", "b", "c" ])), + assert.throws( + () => df.addColumn("new_column", new dfd.Series([ "a", "b", "c" ])), Error, - 'ParamError: Column data length mismatch. You provided data with length 3 but Ndframe has column of length 4'; - }); + 'ParamError: Column data length mismatch. You provided data with length 3 but Ndframe has column of length 4' + ); }); it("Ensure add column does not mutate parent when not in place", function () { diff --git a/src/danfojs-browser/tests/core/generic.test.js b/src/danfojs-browser/tests/core/generic.test.js index 44683e5a..525ca2cb 100644 --- a/src/danfojs-browser/tests/core/generic.test.js +++ b/src/danfojs-browser/tests/core/generic.test.js @@ -59,20 +59,20 @@ describe("Generic (NDFrame)", function () { it("Throws error on duplicate column name", function () { let data = [ [ 21, 20, 1 ], [ 20, 25, 3 ] ]; - assert.throws(() => { - new dfd.NDframe({ data, isSeries: false, columns: [ "A", "A", "C" ] }), + assert.throws( + () => new dfd.NDframe({ data, isSeries: false, columns: [ "A", "A", "C" ] }), Error, - "ColumnIndexError: Column index must contain unique values"; - }); + "ColumnIndexError: Column index must contain unique values" + ); }); it("Throws error on duplicate index", function () { - let data = [ [ 21, 20, 1 ], [ 20, 25, 3 ] ]; - assert.throws(() => { - new dfd.NDframe({ data, isSeries: false, index: [ 1, 1, 2 ] }), + let data = [ [ 21, 20, 1 ], [ 20, 25, 3 ], [ 19, 30, 5 ] ]; + assert.throws( + () => new dfd.NDframe({ data, isSeries: false, index: [ 1, 1, 2 ] }), Error, - "IndexError: Row index must contain unique values"; - }); + "IndexError: Row index must contain unique values" + ); }); it("Successfully create a 2D Frame when first value is empty", function () { diff --git a/src/danfojs-node/test/core/frame.test.ts b/src/danfojs-node/test/core/frame.test.ts index 8ed759bb..933e6366 100644 --- a/src/danfojs-node/test/core/frame.test.ts +++ b/src/danfojs-node/test/core/frame.test.ts @@ -128,11 +128,9 @@ describe("DataFrame", function () { const data = { alpha: ["A", "B", "C", "D"], val_count: [1, 2, 3, 4], val_sum: [20.3, 30.456, 40.90, 90.1] }; const df = new DataFrame(data); - assert.throws(function () { - df.addColumn("new_column", new Series(["a", "b", "c"])), - Error, - 'ParamError: Column data length mismatch. You provided data with length 3 but Ndframe has column of length 4' - }) + assert.throws( + () => df.addColumn("new_column", new Series(["a", "b", "c"])), Error, + 'ParamError: Column data length mismatch. You provided data with length 3 but Ndframe has column of length 4'); }); it("Ensure add column does not mutate parent when not in place", function () { diff --git a/src/danfojs-node/test/core/generic.test.ts b/src/danfojs-node/test/core/generic.test.ts index a7c390a0..e484067c 100644 --- a/src/danfojs-node/test/core/generic.test.ts +++ b/src/danfojs-node/test/core/generic.test.ts @@ -62,20 +62,16 @@ describe("Generic (NDFrame)", function () { it("Throws error on duplicate column name", function () { let data = [[21, 20, 1], [20, 25, 3]]; - assert.throws(() => { - new NDframe({ data, isSeries: false, columns: ["A", "A", "C"] }), - Error, - "ColumnIndexError: Column index must contain unique values" - }); + assert.throws( + () => new NDframe({ data, isSeries: false, columns: ["A", "A", "C"] }), Error, + "ColumnIndexError: Column index must contain unique values"); }); it("Throws error on duplicate index", function () { - let data = [[21, 20, 1], [20, 25, 3]]; - assert.throws(() => { - new NDframe({ data, isSeries: false, index: [1, 1, 2] }), - Error, - "IndexError: Row index must contain unique values" - }); + let data = [[21, 20, 1], [20, 25, 3], [19, 30, 5]]; + assert.throws( + () => new NDframe({ data, isSeries: false, index: [1, 1, 2] }), Error, + "IndexError: Row index must contain unique values"); }); it("Successfully create a 2D Frame when first value is empty", function () {