644 Commits

Author SHA1 Message Date
Glen Whitney
7db791298c
fix: #3578 interpret empty true-expr of conditional as error (#3581) 2025-11-12 09:55:51 +01:00
Orel Ben Neriah
b81420fad6
chore: update matrix documentation to align with v15 (#3591)
Resolves #3565.

---------
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
2025-11-11 15:07:16 -08:00
NilsDietrich
48ba6adbca
feat: support for optional chaining object?.key (#3547) 2025-10-29 11:07:52 +01:00
Jos de Jong
302ed812e1
fix: #3529 change function size to always return an Array (#3535) 2025-10-09 10:33:15 +02:00
Jos de Jong
1e3c2a99aa Merge branch 'develop' into v15
# Conflicts:
#	HISTORY.md
2025-09-24 11:25:19 +02:00
Ikem
0b84ce264d
feat: add nullish coalescing operator support (#3497)
Resolves #3353.

* test: enhance nullish coalescing tests for arrays, matrices, and conditional expressions

* docs: add nullish coalescing operator precedence details and update syntax documentation
---------

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
2025-09-17 19:49:15 -04:00
Jos de Jong
a4815d5bd2
feat: implement serialization support for Parser (fixes #3509) (#3525) 2025-09-05 10:18:05 +02:00
Jos de Jong
a8ec24d595 docs: some updates in the description to migrate matrix index behavior to v15 (see #3485) 2025-07-16 10:58:25 +02:00
David Contreras
10602fdbfd
feat: matrix subset according to type of input (#3485) 2025-07-16 10:40:13 +02:00
Jacopo Mercolini
8d19c8b51e
feat: toBest(unit, unitList, offset) function (#3484)
* feat: toBest tests

* feat: toBest function initial

* fix: tests and function changes

* fix: dependencies

* new way to handle

* updated tests

* test updated

* tests fixed

* cleaned useless tests

* cleaned useless condition

* fix: missing comments

* fix: moved tests

* other fix and clean

* change test to work with npx mocha "path" -g "toBest"

* deleted check large and small value

* deleted precision test and fix options to bestprefix

* fix: moved toBest tests in correct file

* fix: math create

* fix: aligned files pre-mr

* fix: toBest docs test

* fix: lint issues

* fix: comments

* fix: added a helper function to simplify the test readability

* fix: unit.md and units.md docs updated

* fix: test on units.length

* added post process denormalize for tobest function to string returned value

* removed this.clone into format

* feat improve incompatible units test

* fix assign prefixes

* fixed examples

* changed order of params of assertUnit

* fixed comments and added toBest in knowProblems at doc.test

* refactor: update toBest functionality and adjust related tests for accuracy

* refactor: remove unnecessary offset initialization in prefix application

---------

Co-authored-by: Luca Quercetti <l.quercetti@wecodeyou.it>
Co-authored-by: Elia Alesiani <elia.alesiani@gmail.com>
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
Co-authored-by: lucaQ <lucaquercetti@gmail.com>
Co-authored-by: EliaAlesiani <105418798+EliaAlesiani@users.noreply.github.com>
2025-07-09 19:16:47 +02:00
Jos de Jong
8e76654c7f Merge branch 'develop' into v15
# Conflicts:
#	AUTHORS
#	HISTORY.md
2025-06-04 10:45:11 +02:00
Jos de Jong
de7865c69a docs: fix broken examples on the "Data types" page 2025-05-21 17:38:18 +02:00
Jos de Jong
2fc69630dc docs: add numberFallback to the example on the Configuration page 2025-05-21 14:44:15 +02:00
Jos de Jong
9b8e32491b docs: document using methods in the parser (fixes #3462) 2025-04-23 13:02:45 +02:00
Glen Whitney
75cd91b7ed
chore: update HISTORY, AUTHORS, and fix doc typo from last commit (#3460) 2025-04-22 16:50:03 -07:00
Kip Robinson
4f748d22ec feat: give unary % operator (percentage) higher precedence than binary % operator (modulus) (#3432) 2025-04-22 15:59:02 -07:00
Glen Whitney
127ea626fc
feat: #3041, #3340 rename apply to mapSlices (#3357)
* chore: Rename `apply` to `mapSlices`

  This renaming conforms with the Julia name for the function formerly
  called `apply`, and allows it to be called from the expression parser.
  The previous name `apply` is kept as an alias for `mapSlices`, for
  backward compatibility. This commit implements an `alias` metadata
  property for function factories to facilitate the `apply` alias for
  `mapSlices`.

  As a separate bonus, this PR corrects several typos in function docs
  and removes now-passing doc tests from the list of "known failing" doc
  tests to get down to 45 known failures and 136 total issues in doc tests.
  (Most of the excess of 136 as compared to 45 are just due to roundoff
  error/slight inaccuracy of what the documentation claims the result will
  be and the actual result returned by mathjs. When the 45 are eliminated,
  a reasonable numeric tolerance can be decided on for doc testing and
  then the doc tests can be made binding rather than advisory.

* refactor: changes per PR review

---------

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2025-01-30 13:19:23 +01:00
Jos de Jong
e93780e6d5 Merge branch 'develop' into v14 2024-11-20 11:41:30 +01:00
Emmanuel Ferdman
7c9c65ac94
docs: update parse.js reference (#3316)
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2024-11-14 16:18:23 +01:00
Neeraj Kumawat
d0f8b2b800
fix: #3301 precedence of % (mod) is higher than * and / (#3311) 2024-11-07 12:08:35 +01:00
Jos de Jong
e50215c903 docs: fix a typo on the Syntax page (#3276) 2024-10-09 08:53:49 +02:00
David Contreras
1d29c273c2
docs: document the syntax of map and forEach in the expression parser (#3272) 2024-10-02 09:42:56 +02:00
Vas Sudanagunta
70d4170dd3
fix broken links in configuration.md (#3254)
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2024-08-27 19:46:57 +02:00
Jos de Jong
ed2cce4d17
fix: various security vulnerabilities (#3255)
* fix: disable parser functions in the CLI (security issue)

* fix: ensure `ObjectWrappingMap` doesn't allow deleting unsafe properties (security issue)

* fix: enable using methods and (safe) properties on plain arrays

* docs: update the "Less vulnerable expression parser" section in the docs

* chore: fix typos and linting issues

* chore: keep functions like `simplify` enabled in the CLI

* docs: update the security page

* fix: ensure `ObjectWrappingMap.keys` cannot list unsafe properties

* fix: when overwriting a rawArgs function with a non-rawArgs function it was still called with raw arguments

* docs: fix a typo
2024-08-27 16:42:46 +02:00
David Contreras
bcf0da46f0
feat: support multiple inputs in function map (#3228) 2024-08-22 13:35:21 +02:00
Jos de Jong
4e2eeac75a fix: #3244 fix broken link to ResultSet in the docs about classes 2024-08-01 11:20:11 +02:00
Jos de Jong
a1eec936fc
feat: export util functions for maps and improve documentation of scope (#3243)
* feat: export util functions `isMap`, `isPartitionedMap`, and `isObjectWrappingMap` and improve the documentation of `scope` (see #3150)

* chore: fix broken unit tests

* docs: refine the explanation about scopes
2024-08-01 10:57:23 +02:00
Jos de Jong
ab3461d484
feat: implement support for bigint (#3207, #2737) 2024-05-31 12:43:09 +02:00
David Contreras
eded7e1dc3
feat: nearly equal with relative and absolute tolerance (#3152)
* nearlyEqual with absolute and relative tolerances

* Format

* nearlyEqual for bigNumber

* Added skip for NaN

* Reduce diff a bit

* Issue with examples in jsdcos

* Updated all calls for nearlyEqual

* Fixed failing tests

* Changed epsilon to relTol, absTol

* Changed references to epsilon in docs and tests

* Added warning for config.epsilon

* Fix warning in zeta.test

* Added config test

* Added sinon to test console.warn

---------

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2024-05-15 10:56:11 +02:00
Jos de Jong
599f4ee804 Fix: outdated, incorrect documentation about the order of precedence for
operator modulus `%`. See #3189
2024-04-29 11:19:44 +02:00
Rohil Shah
a29bab4048
docs: fix misleading documentation for expression tree traverse (#3177)
Callback function for MathNode.traverse() returns void. Documentation says callback must return a replacement for the existing node (possibly copied from transform() above).
2024-03-21 08:43:56 +01:00
Jos de Jong
085b85532c docs: fix broken example in the documentation about matrices (see #3159) 2024-02-16 15:48:12 +01:00
David Contreras
60de1689de
docs: describe getAllAsMap in the Parser docs (#3158) 2024-02-14 17:03:12 +01:00
Jos de Jong
77d13c659f fix: #3155 remove an outdated section about complex numbers from the docs 2024-02-14 09:16:38 +01:00
Jos de Jong
5a4f60fdf6
Fix not being able to use and and or inside a function definition (#3150)
* chore: write unit tests using `and` and `or` inside a function definition (WIP)

* fix: #3143 fix scope issues in rawArgs functions by implementing a `PartitionedMap`

* fix: add more unit tests for `ObjectWrappingMap`

* fix: don't let `ObjectWrappingMap` and `PartitionedMap` extend `Map` (risk of having non-overwritten methods)

* docs: update docs about `rawArgs` functions
2024-02-08 09:53:21 +01:00
Jos de Jong
5fb909ab59 docs: #3145 fix documentation about REPL, it does require a build step nowadays 2024-01-31 09:33:45 +01:00
Alex Edgcomb
af55b125a2
Support new metric prefixes: Q, R, r, and q (#3113)
* added Q, R, r, q metrix prefixes

* tests added for new prefixes

* removed duplicate tests

* maybe square and cubic tests will bump code cov into the positive

* Check numeric value

---------

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2024-01-10 17:29:52 +01:00
Jos de Jong
7e9ff612a0
feat: lazy evaluation of and, or, &, | (#3101, #3090)
* If fn has rawArgs set, pass unevaluated args

* Add shared helper function for evaluating truthiness

* Add and & or transform functions for lazy evaluation

* Add lazy evaluation of bitwise & and | operators

* Add unit tests for lazy evaluation

* Add lazy evaluation note to docs

* Move documentation to Syntax page

* Replace `testCondition()` with test evaluation
of logical function itself

* Use `isCollection()` to simplify bitwise transform functions

* fix: do not copy scope in raw OperatorNode, test lazy operators scope

* fix: linting issues

---------

Co-authored-by: Brooks Smith <brooks.smith@clearcalcs.com>
2023-12-08 16:17:44 +01:00
Jos de Jong
3d84b5b594 fix #3092: a typo in an error message when converting a string into a number 2023-11-09 09:25:43 +01:00
Jos de Jong
a8cc5f9ae5 docs: update links to https://github.com/rawify/Fraction.js 2023-09-04 15:48:35 +02:00
David Contreras
49c793ba5a
feat: Indexing with an array of booleans (#2994)
* Included math to syntax when missing

* Included solveODE

* renamed initialStep as firstStep

* Included tests for solveODE

* Test the full state instead of the final state

* Fixed issue with tolerance

* Indexing with an array of booleans

* Indexing with booleans and with empty

* Changed index embedded docs

* removed solveODE

* typos on tests

* included config.predictable

* Throws an error if the size doesn't match

* Included config predictable to get subset

* Can do replacement by broadcasting

* DenseMatrix set can broadcast first

* Added tests for broadcasted subset in the parser

* Faster cloning of deep arrays

* Included docs and better test coverage

* Test coverage for `subset`

* Removed config predictable from subset

* Removed config from index and sparseMatrix

* Redaction and typos

* Cleanup unnecesary changes

* fixed issue when there is no need to broadcast

* Inline ifs

* Included specific broadcasting test

* Reduced repetition

---------

Co-authored-by: David Contreras <david.contreras@guentner.com>
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2023-07-28 09:30:04 +02:00
Jos de Jong
bc9f4d6243 fix: #2996 two errors in the examples in the documentation about Expression trees 2023-07-10 09:11:57 +02:00
kunalagrwl
6e25f5ac47
fix: #2959 typo in doc (#2963)
* Update parsing.md

Fixing doc typo

* Update parser.js

Fixing typo in doc

* Update Parser.js

Fix typo in doc
2023-06-07 15:30:52 +02:00
David Contreras
ebf92874e2
d was assigned twice to a constant (#2930) 2023-04-21 16:42:03 +02:00
Jos de Jong
db3e62e5c3
feat: extend functions fraction, bignumber, and number with support for units, see #2918 (#2926)
* feat: extend function `fraction` with support for units (see #2918)

* fix: update the TypeScript definitions with the new `math.fraction(value: Unit)` support

* feat: implement `math.bignumber(value: Unit)`

* feat: update type definitions of function `math.bignumber`

* fix: linting issue

* feat: implement support for `math.number(unit)` (was formerly throwing an exception)
2023-04-03 13:48:24 +02:00
Jos de Jong
151baca0af fix #2908: improve docs and examples of functions partitionSelect, diff, expm1, round, nthRoots, sign, rigthArithShift, setIsSubset, setSize, and the docs about units 2023-03-09 11:54:45 +01:00
Jos de Jong
6fb485de5f fix #2906: improve description of the behavior of subset for scalar values in the docs 2023-02-27 11:28:22 +01:00
David Contreras
f8013cc99a
Broadcasting (#2895)
* broadcasting

* Simplified broadcasting

* Updated for broadcasting

* Changed to camel case

* Camel case and auto formating

* Added comments

* Skip if matrices have the same size

* Fixed issue with undefined variable

missing dot  in `A._size`

* Implemented broadcasting in all functions

* Added helper functions

* Added function to check for broadcasting rules

* Tests for broadcasted arithmetic

* Fixed issue with matrix the size of a vector

* Documented and updated broadcasting

* Included broadcast.test

---------

Co-authored-by: David Contreras <david.contreras@guentner.com>
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2023-02-23 19:24:55 +01:00
Jos de Jong
0230a17af5 Fix: split a long sentence in the docs in two 2023-02-08 11:52:29 +01:00
Jos de Jong
edb8b5ffd1 Fix: typo in the docs about calculations with matrices 2023-02-08 11:49:35 +01:00