Skip to content

Commit

Permalink
Merge branch 'develop' into determinant
Browse files Browse the repository at this point in the history
  • Loading branch information
dvd101x committed Feb 5, 2024
2 parents fb4fadb + 9fe4ffe commit e827580
Show file tree
Hide file tree
Showing 9 changed files with 457 additions and 394 deletions.
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ Evan Miller <evan@geteppo.com>
Timur <35872220+bornova@users.noreply.github.com>
Ari Markowitz <ariymarkowitz@gmail.com>
Jay Wang <xiao.hk1997@gmail.com>
David Contreras <david.contreras@guentner.com>
Jaeu Jeong <wodndb@gmail.com>
cyavictor88 <100557319+cyavictor88@users.noreply.github.com>
David Contreras <david.contreras@guentner.com>
Jakub Riegel <jakubriegel112@gmail.com>
Angus Comrie <accomrie@gmail.com>
TMTron <martin.trummer@tmtron.com>
Expand All @@ -238,5 +238,6 @@ Juan Pablo Alvarado <63080419+juancodeaudio@users.noreply.github.com>
Brooks Smith <brooks.smith@clearcalcs.com>
Alex Edgcomb <aedgcomb@gmail.com>
S.Y. Lee <sylee957@gmail.com>
Hudsxn <143907857+Hudsxn@users.noreply.github.com>

# Generated by tools/update-authors.js
6 changes: 5 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# History


# unpublished changes since 12.3.0
# 2024-02-01, 12.3.1

- Improved the typings of the arguments of `ArrayNode`, `FunctionNode`,
`IndexNode`, `OperatorNode`, and `RelationalNode` (#3123). Thanks @sylee957.
Expand All @@ -12,6 +12,10 @@
- Fix: #3142 support BigNumber values for the options of function `format`:
`precision`, `wordSize`, `lowerExp`, `upperExp`. Support BigNumber values
for the option `wordSize` in the functions `hex`, `bin`, and `oct`.
- Fix: #3125 type definitions of function `hypot` (#3144).
Thanks @silentmissile.
- Fix: #3141 `help(config)` altering the actual `config` when evaluating the
examples.
- Docs: #3145 fix documentation about REPL, it does require a build step
nowadays.

Expand Down
781 changes: 408 additions & 373 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mathjs",
"version": "12.3.0",
"version": "12.3.1",
"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.23.8",
"@babel/runtime": "^7.23.9",
"complex.js": "^2.1.1",
"decimal.js": "^10.4.3",
"escape-latex": "^1.2.0",
Expand All @@ -36,21 +36,21 @@
"typed-function": "^4.1.1"
},
"devDependencies": {
"@babel/core": "7.23.7",
"@babel/core": "7.23.9",
"@babel/plugin-transform-object-assign": "7.23.3",
"@babel/plugin-transform-runtime": "7.23.7",
"@babel/preset-env": "7.23.8",
"@babel/plugin-transform-runtime": "7.23.9",
"@babel/preset-env": "7.23.9",
"@babel/register": "7.23.7",
"@types/assert": "1.5.10",
"@types/mocha": "10.0.6",
"@typescript-eslint/eslint-plugin": "6.18.1",
"@typescript-eslint/parser": "6.18.1",
"@typescript-eslint/eslint-plugin": "6.20.0",
"@typescript-eslint/parser": "6.20.0",
"assert": "2.1.0",
"babel-loader": "9.1.3",
"benchmark": "2.1.4",
"c8": "9.0.0",
"c8": "9.1.0",
"codecov": "3.8.3",
"core-js": "3.35.0",
"core-js": "3.35.1",
"del": "6.1.1",
"dtslint": "4.2.1",
"eslint": "8.56.0",
Expand Down Expand Up @@ -85,12 +85,12 @@
"ndarray-pack": "1.2.1",
"numericjs": "1.2.6",
"pad-right": "0.2.2",
"prettier": "3.1.1",
"prettier": "3.2.4",
"process": "0.11.10",
"sylvester": "0.0.21",
"ts-node": "10.9.2",
"typescript": "5.3.3",
"webpack": "5.89.0",
"webpack": "5.90.0",
"zeros": "1.0.0"
},
"type": "module",
Expand Down Expand Up @@ -175,4 +175,4 @@
"url": "https://github.com/josdejong/mathjs/issues"
},
"sideEffects": false
}
}
23 changes: 19 additions & 4 deletions src/expression/Help.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { format } from '../utils/string.js'
import { factory } from '../utils/factory.js'

const name = 'Help'
const dependencies = ['parse']
const dependencies = ['evaluate']

export const createHelpClass = /* #__PURE__ */ factory(name, dependencies, ({ parse }) => {
export const createHelpClass = /* #__PURE__ */ factory(name, dependencies, ({ evaluate }) => {
/**
* Documentation object
* @param {Object} doc Object containing properties:
Expand Down Expand Up @@ -58,15 +58,26 @@ export const createHelpClass = /* #__PURE__ */ factory(name, dependencies, ({ pa
if (doc.examples) {
desc += 'Examples:\n'

const scope = {}
// after evaluating the examples, we restore config in case the examples
// did change the config.
let configChanged = false
const originalConfig = evaluate('config()')

const scope = {
config: (newConfig) => {
configChanged = true
return evaluate('config(newConfig)', { newConfig })
}
}

for (let i = 0; i < doc.examples.length; i++) {
const expr = doc.examples[i]
desc += ' ' + expr + '\n'

let res
try {
// note: res can be undefined when `expr` is an empty string
res = parse(expr).compile().evaluate(scope)
res = evaluate(expr, scope)
} catch (e) {
res = e
}
Expand All @@ -75,6 +86,10 @@ export const createHelpClass = /* #__PURE__ */ factory(name, dependencies, ({ pa
}
}
desc += '\n'

if (configChanged) {
evaluate('config(originalConfig)', { originalConfig })
}
}
if (doc.mayThrow && doc.mayThrow.length) {
desc += 'Throws: ' + doc.mayThrow.join(', ') + '\n\n'
Expand Down
2 changes: 1 addition & 1 deletion src/version.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const version = '12.3.0'
export const version = '12.3.1'
// Note: This file is automatically generated when building math.js.
// Changes made in this file will be overwritten.
2 changes: 1 addition & 1 deletion test/generated-code-tests/entry/mainAny.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('mainAny', function () {
assert.deepStrictEqual(scope, { b: 2 })
})

it('should evaluate assignement and access', function () {
it('should evaluate assignment and access', function () {
const math = create(all)
const evaluate = math.evaluate

Expand Down
7 changes: 7 additions & 0 deletions test/unit-tests/expression/function/help.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ describe('help', function () {
assert.strictEqual(help.doc.name, 'sin')
})

it('should not alter the mathjs instance when stringifying help', function () {
const config = math.config()
const str = math.help(math.config).toString()
assert(str.includes('number: "Fraction"'))
assert.deepStrictEqual(math.config(), config)
})

it('should find help from a function', function () {
const help = math.help(math.sin)
assert(help instanceof math.Help)
Expand Down
3 changes: 2 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,8 @@ export interface MathJsInstance extends MathJsFactory {
* whole matrix.
* @returns Returns the hypothenuse of the input values.
*/
hypot<T extends (number | BigNumber)[]>(...args: T[]): T
hypot<T extends number | BigNumber>(...args: T[]): T
hypot<T extends number | BigNumber>(args: T[]): T

/**
* Calculate the least common multiple for two or more values or arrays.
Expand Down

0 comments on commit e827580

Please sign in to comment.