Removes out-of-bounds access to first element in optimizeCallback when
the provided array/matrix is empty. Also adds numerous unit tests for such
edge cases, and fixes a previously unreported internal bug in SparseMatrix,
violating its own invariants on empty matrices.
Resolves#3564.
---------
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
* sign of zero fraction should return 0/1 instead of 1/1
* moved fraction zero test into correct fraction block
* moved fraction zero test into correct fraction block
* 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>
Previously `math.kron()` always returned a 2D matrix, and could not handle 3D or greater arrays. Now it always returns an array of the max dimension of its arguments.
Resolves#1753.
---------
Co-authored-by: Delaney Sylvans <delaneysylvans@gmail.com>
Previously `math.kron()` always returned a 2D matrix, and could not handle 3D or greater arrays. Now it always returns an array of the max dimension of its arguments.
Resolves#1753.
---------
Co-authored-by: Delaney Sylvans <delaneysylvans@gmail.com>
Previously, when a valueless unit multiplied/divided something with a numerical value, it would just use ordinary 1 of type `number` in place of its null value. Now it matches the type of one used with the other numerical value.
Resolves#3450.
---------
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
* fix: use utility isNaN for consistent max and min results
* test: add NaN comparison cases for larger and smaller functions
* docs: update descriptions for larger, smaller, max, and min functions to clarify NaN behavior
* refactor: rename isNaN to mathIsNaN for extra clarity
---------
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
* refactor: simplify flatten function using Array.prototype.flat
* Added fallback
* added option to flatten arrays with homogeneous size
* Typos in array.js and array.test.js
* fix types in jsdocs
* Renamed variable
* Reverted to original form
---------
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
* 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>
* fix: Accept bigints as matrix indices and range params, demoting to number
* feat: bigint support in range(), clarify demotion in Range()
* feat: range() support Fraction, better errors for single non-string argument
---------
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
* fix: Don't override type-native floor/ceil when within tolerance of value
* refactor: extend bigint safety to round and fix
---------
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
* fix: Handle bigints properly in more cases
* Allow a bigint to appear in a max/min of nonhomogeneous arguments
* If randomInt is called with a bigint or a pair of bigints, return
a bigint.
* Preserve uniformity of results if randomInt is called with a very large
range.
* Extend log, log2, and log10 to bigints
* Add tests for all of the above issues.
* Bonus: fix one JSDoc comment issue. If every PR fixes one, we will soon
get through the 150+
* fix: Refactors per comments and 1 bonus doc test (isInteger)
* chore: fix lint
---------
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>