-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Description
It seems that i with any subscript is not being processed properly, very similar to #255. The compute engine still tries to treat i as a complex number, instead of treating i_A as its own variable.
Steps to Reproduce
import { ComputeEngine } from "@cortex-js/compute-engine";
const ce = new ComputeEngine();
const BATCH_1 = [
'i',
'i+1',
'i_A',
'i_A+1',
'\frac{i_{A}}{i}',
];
function convertLatexToMathJson(latex) {
const parsedExpr = ce.parse(latex);
const boxedExpr = ce.box(parsedExpr, { canonical: true });
return boxedExpr.json;
}
// Run testing
console.log('Batch 1 Testing');
for (const expr of BATCH_1) {
const mjson = convertLatexToMathJson(expr);
console.log(expr, ' => ', JSON.stringify(mjson, null, 2));
}Actual Result
Batch 1 Testing
i => [
"Complex",
0,
1
]
i+1 => [
"Add",
1,
[
"Complex",
0,
1
]
]
i_A => [
"Subscript",
[
"Complex",
0,
1
],
"A"
]
i_A+1 => [
"Add",
[
"Error",
[
"ErrorCode",
"'incompatible-type'",
"number",
"expression"
]
],
1
]
\frac{i_{A}}{i} => [
"Divide",
[
"Error",
[
"ErrorCode",
"'incompatible-type'",
"number",
"expression"
]
],
[
"Complex",
0,
1
]
]
Environment
Testing code is ran against Node.js v22.20.0 and NPM v10.9.3 using compute engine v0.30.2.
Metadata
Metadata
Assignees
Labels
No labels