diff --git a/src/function/utils/isNaN.js b/src/function/utils/isNaN.js index b12f224276..36e985d695 100644 --- a/src/function/utils/isNaN.js +++ b/src/function/utils/isNaN.js @@ -54,8 +54,6 @@ export const createIsNaN = /* #__PURE__ */ factory(name, dependencies, ({ typed return Number.isNaN(x.value) }, - 'Array | Matrix': function (x) { - return deepMap(x, Number.isNaN) - } + 'Array | Matrix': typed.referToSelf(self => x => deepMap(x, self)) }) }) diff --git a/test/unit-tests/function/utils/isNaN.test.js b/test/unit-tests/function/utils/isNaN.test.js index 97d5c7db01..e7e586da05 100644 --- a/test/unit-tests/function/utils/isNaN.test.js +++ b/test/unit-tests/function/utils/isNaN.test.js @@ -59,14 +59,18 @@ describe('isNegative', function () { assert.strictEqual(isNaN(''), false) }) - it('should test isNegative element wise on an Array', function () { + it('should test isNaN element wise on an Array', function () { assert.deepStrictEqual(isNaN([0, 5, -2, NaN]), [false, false, false, true]) }) - it('should test isNegative element wise on a Matrix', function () { + it('should test isNaN element wise on a Matrix', function () { assert.deepStrictEqual(isNaN(math.matrix([0, 5, -2, NaN])), math.matrix([false, false, false, true])) }) + it('should test isNaN element wise on a Matrix of units', function () { + assert.deepStrictEqual(isNaN(math.matrix([new Unit(3, 'ft'), new Unit(NaN, 'ft')])), math.matrix([false, true])) + }) + it('should throw an error in case of unsupported data types', function () { assert.throws(function () { isNaN(new Date()) }, /TypeError: Unexpected type of argument/) assert.throws(function () { isNaN({}) }, /TypeError: Unexpected type of argument/)