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

fix: fix interpolation function plotting bug #310

Merged
merged 1 commit into from
Dec 23, 2024
Merged
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
6 changes: 2 additions & 4 deletions src/parser/LatexToSympy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ export class LatexToSympy extends LatexParserVisitor<string | Statement | UnitBl
unitQueryArgument.sympy = newArguments[0].sympy;
} else {
// numerical lower limit without units, replace with unitless implicit param to prevent cancelling
unitQueryArgument.sympy = this.getUnitlessImplicitParam();
unitQueryArgument.sympy = this.getUnitlessImplicitParam(newArguments[0].sympy);
}

unitQueryArgument.params = this.params.slice(initialParamCursor);
Expand Down Expand Up @@ -2083,14 +2083,12 @@ export class LatexToSympy extends LatexParserVisitor<string | Statement | UnitBl
}
}

getUnitlessImplicitParam(value=1): string {
getUnitlessImplicitParam(valueString:string): string {
const newParamName = this.getNextParName();

const units = 'm/m';
const mathjsUnits = unit(units);

const valueString = value.toString();

let param: ImplicitParameter = {
name: newParamName,
units: units,
Expand Down
32 changes: 32 additions & 0 deletions tests/test_data_table.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,4 +1355,36 @@ test('Test data table user function exponent bug', async () => {

let content = await page.textContent(`#result-value-1`);
expect(content).toBe(String.raw`\begin{bmatrix} 2\left\lbrack m\right\rbrack \\ 4\left\lbrack m\right\rbrack \\ 8\left\lbrack m\right\rbrack \end{bmatrix}`);
});

test('Test linear interpolation with plotting', async () => {
const modifierKey = (await page.evaluate('window.modifierKey') )=== "metaKey" ? "Meta" : "Control";

await page.locator('#add-data-table-cell').click();

await page.locator('#data-table-input-1-0-0').click();

await page.keyboard.type('10');
await page.keyboard.press('Tab');
await page.keyboard.type('1');
await page.keyboard.press('Enter');

await page.keyboard.type('20');
await page.keyboard.press('Tab');
await page.keyboard.type('2');
await page.keyboard.press('Enter');

await page.keyboard.type('30');
await page.keyboard.press('Tab');
await page.keyboard.type('3');

await page.getByRole('button', { name: 'Add Interpolation' }).click();
await page.getByLabel('Copy function name to').click();

await page.locator('#cell-0 >> math-field.editable').type('(x,');
await page.locator('#cell-0 >> math-field.editable').press(modifierKey+'+v');
await page.locator('#cell-0 >> math-field.editable').type('(x)) for (10<=x<=30)=');

await page.waitForSelector('div.status-footer', {state: 'detached'});
await expect(page.locator('g.trace.scatter')).toBeVisible();
});
Loading