diff --git a/AUTHORS b/AUTHORS index 562e71de76..2d36361a01 100644 --- a/AUTHORS +++ b/AUTHORS @@ -217,7 +217,6 @@ Evan Miller Timur <35872220+bornova@users.noreply.github.com> Ari Markowitz Jay Wang -David Contreras cyavictor88 <100557319+cyavictor88@users.noreply.github.com> David Contreras @@ -232,6 +231,7 @@ MaybePixem <47889538+MaybePixem@users.noreply.github.com> Aly Khaled BuildTools Anik Patel <74193405+Bobingstern@users.noreply.github.com> -Vrushaket Chaudhari +Vrushaket Chaudhari <82214275+vrushaket@users.noreply.github.com> +vrushaket # Generated by tools/update-authors.js diff --git a/src/function/statistics/corr.js b/src/function/statistics/corr.js index 330f89b5b6..10bdd14c72 100644 --- a/src/function/statistics/corr.js +++ b/src/function/statistics/corr.js @@ -67,6 +67,9 @@ export const createCorr = /* #__PURE__ */ factory(name, dependencies, ({ typed, } return correlations } else { + if (A.length !== B.length) { + throw new SyntaxError('Dimension mismatch. Array A and B must have the same number of elements.') + } return correlation(A, B) } } diff --git a/test/unit-tests/function/statistics/corr.test.js b/test/unit-tests/function/statistics/corr.test.js index 6f7c7e87e3..7fbbe8a7ec 100644 --- a/test/unit-tests/function/statistics/corr.test.js +++ b/test/unit-tests/function/statistics/corr.test.js @@ -33,10 +33,13 @@ describe('correlation', function () { }) it('should throw an error if called with different number of arguments', function () { - assert.throws(function () { corr([[1, 2, 3, 4, 5], [4, 5, 6, 7, 8],[9, 10, 11, 12]], [[1, 2, 3, 4, 5],[4, 5, 6, 7, 8]]) }) + assert.throws(function () { corr([[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [9, 10, 11, 12]], [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8]]) }) }) it('should throw an error if called with number of arguments do not have same size', function () { - assert.throws(function () { corr([[1, 2, 3, 4, 5], [4, 5, 6, 7]], [[1, 2, 3, 4, 5],[]]) }) + assert.throws(function () { corr([[1, 2, 3, 4, 5], [4, 5, 6, 7]], [[1, 2, 3, 4, 5], []]) }) + }) + it('should throw an error if called with number of arguments do not have same size', function () { + assert.throws(function () { corr([1, 2, 3, 4, 5], [1, 2, 3, 4]) }) }) })