Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Apr 24, 2024
2 parents b0be50a + a9fbb35 commit 65ebf5c
Show file tree
Hide file tree
Showing 12 changed files with 2,870 additions and 7,588 deletions.
2 changes: 2 additions & 0 deletions AUTHORS
Expand Up @@ -244,5 +244,7 @@ Rich Martinez <richmartinez@Edinas-MacBook-Pro.local>
RandomGamingDev <83996185+RandomGamingDev@users.noreply.github.com>
Brian Fugate <fugateb@yahoo.com>
Sukka <isukkaw@gmail.com>
Rohil Shah <shah5963@gmail.com>
Laurent Gérin <41303636+lgerin@users.noreply.github.com>

# Generated by tools/update-authors.js
9 changes: 9 additions & 0 deletions HISTORY.md
@@ -1,5 +1,14 @@
# History

# 2024-04-24, 12.4.2

- Fix #3192: function `isNaN` returns `false` for `NaN` units in a matrix or
array (#3193). Thanks @lgerin.
- Fix: #3180 fix type definitions of functions `add` and `multiply` to allow
more than two arguments.
- Docs: correct the docs about `traverse` returning void (#3177).
Thanks @rohildshah.


# 2024-03-13, 12.4.1

Expand Down
2 changes: 1 addition & 1 deletion docs/expressions/expression_trees.md
Expand Up @@ -213,7 +213,7 @@ All nodes have the following methods:
this node and each of its child nodes. Similar to `Array.forEach`, except
recursive.
The callback function is a mapping function accepting a node, and returning
a replacement for the node or the original node. Function `callback` is
nothing. Function `callback` is
called as `callback(node: Node, path: string, parent: Node)` for every node
in the tree. Parameter `path` is a string containing a relative JSON Path.
Example:
Expand Down
10,383 changes: 2,824 additions & 7,559 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "mathjs",
"version": "12.4.1",
"version": "12.4.2",
"description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
"author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
"homepage": "https://mathjs.org",
Expand All @@ -25,7 +25,7 @@
"unit"
],
"dependencies": {
"@babel/runtime": "^7.24.0",
"@babel/runtime": "^7.24.4",
"complex.js": "^2.1.1",
"decimal.js": "^10.4.3",
"escape-latex": "^1.2.0",
Expand All @@ -36,36 +36,36 @@
"typed-function": "^4.1.1"
},
"devDependencies": {
"@babel/core": "7.24.0",
"@babel/plugin-transform-object-assign": "7.23.3",
"@babel/plugin-transform-runtime": "7.24.0",
"@babel/preset-env": "7.24.0",
"@babel/core": "7.24.4",
"@babel/plugin-transform-object-assign": "7.24.1",
"@babel/plugin-transform-runtime": "7.24.3",
"@babel/preset-env": "7.24.4",
"@babel/register": "7.23.7",
"@types/assert": "1.5.10",
"@types/mocha": "10.0.6",
"@typescript-eslint/eslint-plugin": "7.2.0",
"@typescript-eslint/parser": "7.2.0",
"@typescript-eslint/eslint-plugin": "7.7.1",
"@typescript-eslint/parser": "7.7.1",
"assert": "2.1.0",
"babel-loader": "9.1.3",
"benchmark": "2.1.4",
"c8": "9.1.0",
"codecov": "3.8.3",
"core-js": "3.36.0",
"core-js": "3.37.0",
"del": "6.1.1",
"dtslint": "4.2.1",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-config-standard": "17.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-mocha": "10.4.1",
"eslint-plugin-mocha": "10.4.3",
"eslint-plugin-n": "16.6.2",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-promise": "6.1.1",
"expect-type": "0.18.0",
"expect-type": "0.19.0",
"expr-eval": "2.0.2",
"fancy-log": "2.0.0",
"glob": "8.1.0",
"gulp": "4.0.2",
"gulp": "5.0.0",
"gulp-babel": "8.0.0",
"handlebars": "4.7.8",
"jsep": "1.3.8",
Expand All @@ -76,7 +76,7 @@
"karma-mocha-reporter": "2.2.5",
"karma-webpack": "5.0.1",
"mkdirp": "3.0.1",
"mocha": "10.3.0",
"mocha": "10.4.0",
"mocha-junit-reporter": "2.2.1",
"ndarray": "1.0.19",
"ndarray-determinant": "1.0.0",
Expand All @@ -89,8 +89,8 @@
"process": "0.11.10",
"sylvester": "0.0.21",
"ts-node": "10.9.2",
"typescript": "5.4.2",
"webpack": "5.90.3",
"typescript": "5.4.5",
"webpack": "5.91.0",
"zeros": "1.0.0"
},
"type": "module",
Expand Down
6 changes: 3 additions & 3 deletions src/core/create.js
@@ -1,5 +1,5 @@
import typedFunction from 'typed-function'
import { deepFlatten, isLegacyFactory, values } from '../utils/object.js'
import { deepFlatten, isLegacyFactory } from '../utils/object.js'
import * as emitter from './../utils/emitter.js'
import { importFactory } from './function/import.js'
import { configFactory } from './function/config.js'
Expand Down Expand Up @@ -216,7 +216,7 @@ export function create (factories, config) {
// listen for changes in config, import all functions again when changed
// TODO: move this listener into the import function?
math.on('config', () => {
values(importedFactories).forEach(factory => {
Object.values(importedFactories).forEach(factory => {
if (factory && factory.meta && factory.meta.recreateOnConfigChange) {
// FIXME: only re-create when the current instance is the same as was initially created
// FIXME: delete the functions/constants before importing them again?
Expand All @@ -234,7 +234,7 @@ export function create (factories, config) {

// import the factory functions like createAdd as an array instead of object,
// else they will get a different naming (`createAdd` instead of `add`).
math.import(values(deepFlatten(factories)))
math.import(Object.values(deepFlatten(factories)))

math.ArgumentsError = ArgumentsError
math.DimensionError = DimensionError
Expand Down
4 changes: 1 addition & 3 deletions src/function/utils/isNaN.js
Expand Up @@ -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))
})
})
4 changes: 0 additions & 4 deletions src/utils/object.js
Expand Up @@ -390,10 +390,6 @@ export function pickShallow (object, properties) {
return copy
}

export function values (object) {
return Object.keys(object).map(key => object[key])
}

// helper function to test whether a string contains a path like 'user.name'
function isPath (str) {
return str.indexOf('.') !== -1
Expand Down
2 changes: 1 addition & 1 deletion src/version.js
@@ -1,3 +1,3 @@
export const version = '12.4.1'
export const version = '12.4.2'
// Note: This file is automatically generated when building math.js.
// Changes made in this file will be overwritten.
4 changes: 4 additions & 0 deletions test/typescript-tests/testTypes.ts
Expand Up @@ -79,6 +79,10 @@ Basic usage examples
math.pow(m2by2, 2)
const angle = 0.2
math.add(math.pow(math.sin(angle), 2), math.pow(math.cos(angle), 2))
math.add(2, 3, 4)
math.add(2, 3, math.bignumber(4))
math.multiply(2, 3, 4)
math.multiply(2, 3, math.bignumber(4))

// std and variance check

Expand Down
8 changes: 6 additions & 2 deletions test/unit-tests/function/utils/isNaN.test.js
Expand Up @@ -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/)
Expand Down
4 changes: 4 additions & 0 deletions types/index.d.ts
Expand Up @@ -1036,7 +1036,9 @@ export interface MathJsInstance extends MathJsFactory {
* @returns Sum of x and y
*/
add<T extends MathType>(x: T, y: T): T
add<T extends MathType>(...values: T[]): T
add(x: MathType, y: MathType): MathType
add(...values: MathType[]): MathType

/**
* Calculate the cubic root of a value.
Expand Down Expand Up @@ -1283,6 +1285,8 @@ export interface MathJsInstance extends MathJsFactory {
multiply(x: Unit, y: Unit): Unit
multiply(x: number, y: number): number
multiply(x: MathType, y: MathType): MathType
multiply<T extends MathType>(...values: T[]): T
multiply(...values: MathType[]): MathType

/**
* Calculate the norm of a number, vector or matrix. The second
Expand Down

0 comments on commit 65ebf5c

Please sign in to comment.