Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added field of boolean type to config for enabling/disabling of implicit multiplication. #1502

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ export const DEFAULT_CONFIG = {

// random seed for seeded pseudo random number generation
// null = randomly seed
randomSeed: null
randomSeed: null,

// Implicit multiplication boolean
implicitMultiplication: true
}
3 changes: 3 additions & 0 deletions src/core/function/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export function configFactory (config, emit) {
* {string} randomSeed
* Random seed for seeded pseudo random number generator.
* Set to null to randomly seed.
* {boolean} implicitMultiplication
* Boolean to set implicit multiplication.
* Default set to true
* @return {Object} Returns the current configuration
*/
function _config (options) {
Expand Down
15 changes: 10 additions & 5 deletions test/entry/bundleAny.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ describe('bundleAny', function () {
precision: 64,
predictable: false,
epsilon: 1e-12,
randomSeed: null
randomSeed: null,
implicitMultiplication: true
})
})

it('should create an instance of math.js with custom configuration', function () {
const math1 = math.create({
matrix: 'Array',
number: 'BigNumber'
number: 'BigNumber',
implicitMultiplication: false
})

assert.strictEqual(typeof math1, 'object')
Expand All @@ -27,7 +29,8 @@ describe('bundleAny', function () {
precision: 64,
predictable: false,
epsilon: 1e-12,
randomSeed: null
randomSeed: null,
implicitMultiplication: false
})
})

Expand Down Expand Up @@ -70,7 +73,8 @@ describe('bundleAny', function () {
precision: 4,
predictable: true,
epsilon: 1e-12,
randomSeed: null
randomSeed: null,
implicitMultiplication: true
})

assert.ok(math1.isNaN(math1.sqrt(-4)))
Expand All @@ -90,7 +94,8 @@ describe('bundleAny', function () {
precision: 64,
predictable: false,
epsilon: 1e-12,
randomSeed: null
randomSeed: null,
implicitMultiplication: true
})

assert.deepStrictEqual(math1.sqrt(-4), math1.complex(0, 2))
Expand Down