Skip to content

Commit

Permalink
fix: change toTex variable and function assignment from := to = (…
Browse files Browse the repository at this point in the history
…see #2980, #3032)
  • Loading branch information
josdejong committed Oct 11, 2023
1 parent 33cb3d6 commit c19c15f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/expression/node/AssignmentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export const createAssignmentNode = /* #__PURE__ */ factory(name, dependencies,
value = `\\left(${value}\\right)`
}

return object + index + ':=' + value
return object + index + '=' + value
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/expression/node/FunctionAssignmentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export const createFunctionAssignmentNode = /* #__PURE__ */ factory(name, depend
}

return '\\mathrm{' + this.name +
'}\\left(' + this.params.map(toSymbol).join(',') + '\\right):=' + expr
'}\\left(' + this.params.map(toSymbol).join(',') + '\\right)=' + expr
}
}

Expand Down
6 changes: 3 additions & 3 deletions test/unit-tests/expression/node/AssignmentNode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ describe('AssignmentNode', function () {
const n = new AssignmentNode(object, value)

assert.strictEqual(n.toString({ parenthesis: 'all' }), 'a = (1)')
assert.strictEqual(n.toTex({ parenthesis: 'all' }), ' a:=\\left(1\\right)')
assert.strictEqual(n.toTex({ parenthesis: 'all' }), ' a=\\left(1\\right)')
})

it('should stringify a AssignmentNode', function () {
Expand Down Expand Up @@ -532,15 +532,15 @@ describe('AssignmentNode', function () {
const value = new ConstantNode(2)
const a = new AssignmentNode(new SymbolNode('a'), value)

assert.strictEqual(a.toTex(), ' a:=2')
assert.strictEqual(a.toTex(), ' a=2')
})

it('should LaTeX an AssignmentNode containing an AssignmentNode', function () {
const value = new ConstantNode(2)
const a = new AssignmentNode(new SymbolNode('a'), value)
const q = new AssignmentNode(new SymbolNode('q'), a)

assert.strictEqual(q.toTex(), ' q:=\\left( a:=2\\right)')
assert.strictEqual(q.toTex(), ' q=\\left( a=2\\right)')
})

it('should LaTeX an AssignmentNode with custom toTex', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/expression/node/BlockNode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ describe('BlockNode', function () {
{ node: new SymbolNode('foo'), visible: true }
])

assert.strictEqual(n.toTex(), '5\\;\\;\n foo:=3;\\;\\;\n foo')
assert.strictEqual(n.toTex(), '5\\;\\;\n foo=3;\\;\\;\n foo')
})

it('should LaTeX a BlockNode with custom toTex', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/expression/node/ConditionalNode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ describe('ConditionalNode', function () {
const n = new ConditionalNode(condition, a, b)

// note that b is enclosed in \\mathrm{...} since it's a unit
assert.strictEqual(n.toTex(), '\\begin{cases} { a:=2}, &\\quad{\\text{if }\\;true}\\\\{\\mathrm{b}:=3}, &\\quad{\\text{otherwise}}\\end{cases}')
assert.strictEqual(n.toTex(), '\\begin{cases} { a=2}, &\\quad{\\text{if }\\;true}\\\\{\\mathrm{b}=3}, &\\quad{\\text{otherwise}}\\end{cases}')
})

it('should LaTeX a ConditionalNode with custom toTex', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ describe('FunctionAssignmentNode', function () {
it('should respect the \'all\' parenthesis option', function () {
const expr = math.parse('f(x)=x+1')
assert.strictEqual(expr.toString({ parenthesis: 'all' }), 'f(x) = (x + 1)')
assert.strictEqual(expr.toTex({ parenthesis: 'all' }), '\\mathrm{f}\\left(x\\right):=\\left( x+1\\right)')
assert.strictEqual(expr.toTex({ parenthesis: 'all' }), '\\mathrm{f}\\left(x\\right)=\\left( x+1\\right)')
})

it('should stringify a FunctionAssignmentNode', function () {
Expand Down Expand Up @@ -466,7 +466,7 @@ describe('FunctionAssignmentNode', function () {
const p = new OperatorNode('^', 'pow', [o, a])
const n = new FunctionAssignmentNode('f', ['x'], p)

assert.strictEqual(n.toTex(), '\\mathrm{f}\\left(x\\right):=\\left({\\frac{ x}{2}}\\right)^{2}')
assert.strictEqual(n.toTex(), '\\mathrm{f}\\left(x\\right)=\\left({\\frac{ x}{2}}\\right)^{2}')
})

it('should LaTeX a FunctionAssignmentNode containing an AssignmentNode', function () {
Expand All @@ -475,7 +475,7 @@ describe('FunctionAssignmentNode', function () {
const n1 = new AssignmentNode(new SymbolNode('a'), a)
const n = new FunctionAssignmentNode('f', ['x'], n1)

assert.strictEqual(n.toTex(), '\\mathrm{f}\\left(x\\right):=\\left( a:=2\\right)')
assert.strictEqual(n.toTex(), '\\mathrm{f}\\left(x\\right)=\\left( a=2\\right)')
})

it('should LaTeX a FunctionAssignmentNode with custom toTex', function () {
Expand Down

0 comments on commit c19c15f

Please sign in to comment.