Skip to content

Commit

Permalink
refactor: update some property names for consistent style
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreminger committed Oct 26, 2023
1 parent fd43c45 commit 7d945aa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
3 changes: 2 additions & 1 deletion public/dimensional_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ class RangeQueryStatement(BaseQueryStatement):
upperLimitArgument: str
upperLimitInclusive: bool
unitsQueryFunction: str
input_units: str
inputUnits: str
inputUnitsLatex: str
outputName: str

class ScatterXValuesQueryStatement(QueryAssignmentCommon):
Expand Down
4 changes: 2 additions & 2 deletions src/PlotCell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
if (plotCell.mathFields[0].statement?.type === "query" && plotCell.mathFields[0].statement.isRange) {
// use input units from first plot statement
userInputUnits = plotCell.mathFields[0].statement.input_units;
userInputUnitsLatex = plotCell.mathFields[0].statement.input_units_latex;
userInputUnits = plotCell.mathFields[0].statement.inputUnits;
userInputUnitsLatex = plotCell.mathFields[0].statement.inputUnitsLatex;
}
for (const [j, statement] of plotCell.mathFields.map((field) => field.statement).entries()) {
if ($results[index] && $results[index][j] &&
Expand Down
34 changes: 17 additions & 17 deletions src/parser/LatexToSympy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { getBlankMatrixLatex } from "../utility";
type UnitBlockData = {
units: string;
unitsLatex: string;
units_valid: boolean;
unitsValid: boolean;
dimensions: number[];
}

Expand Down Expand Up @@ -113,8 +113,8 @@ export class LatexToSympy extends LatexParserVisitor<string | Statement | UnitBl
argumentIndex = 0;
argumentPrefix = "argument__";

input_units = "";
input_units_latex = "";
inputUnits = "";
inputUnitsLatex = "";

constructor(sourceLatex: string, equationIndex: number, type: FieldTypes = "math") {
super();
Expand Down Expand Up @@ -460,7 +460,7 @@ export class LatexToSympy extends LatexParserVisitor<string | Statement | UnitBl
visitQuery = (ctx: QueryContext): QueryStatement | RangeQueryStatement | CodeFunctionQueryStatement => {
let sympy = this.visit(ctx.expr()) as string;

const {units, unitsLatex, units_valid, dimensions} = this.visitU_block(ctx.u_block());
const {units, unitsLatex, unitsValid, dimensions} = this.visitU_block(ctx.u_block());

const initialQuery: QueryStatement = {
type: "query",
Expand Down Expand Up @@ -508,8 +508,8 @@ export class LatexToSympy extends LatexParserVisitor<string | Statement | UnitBl
upperLimitArgument: rangeFunction.upperLimitArgument,
upperLimitInclusive: rangeFunction.upperLimitInclusive,
unitsQueryFunction: rangeFunction.unitsQueryFunction,
input_units: this.input_units,
input_units_latex: this.input_units_latex,
inputUnits: this.inputUnits,
inputUnitsLatex: this.inputUnitsLatex,
outputName: rangeFunction.sympy,
}
}
Expand Down Expand Up @@ -641,7 +641,7 @@ export class LatexToSympy extends LatexParserVisitor<string | Statement | UnitBl
return {type: "error"};
}

const {units, unitsLatex, units_valid, dimensions} = this.visitU_block(ctx.u_block());
const {units, unitsLatex, unitsValid, dimensions} = this.visitU_block(ctx.u_block());

return {
type: "query",
Expand Down Expand Up @@ -926,8 +926,8 @@ export class LatexToSympy extends LatexParserVisitor<string | Statement | UnitBl
this.arguments.push(...newArguments);

if (inputUnitsParameter) {
this.input_units = inputUnitsParameter.units;
this.input_units_latex = inputUnitsParameter.unitsLatex;
this.inputUnits = inputUnitsParameter.units;
this.inputUnitsLatex = inputUnitsParameter.unitsLatex;
}
}

Expand Down Expand Up @@ -1408,7 +1408,7 @@ export class LatexToSympy extends LatexParserVisitor<string | Statement | UnitBl

const original_value = this.visitNumber(ctx.number_());

if (unitBlockData.units_valid) {
if (unitBlockData.unitsValid) {
try{
numWithUnits = unit(
bignumber(original_value),
Expand Down Expand Up @@ -1493,8 +1493,8 @@ export class LatexToSympy extends LatexParserVisitor<string | Statement | UnitBl
visitU_block = (ctx: U_blockContext): UnitBlockData => {
let units = "";
let unitsLatex = "";
let units_valid = false;
let units_dimensions: number[] = [];
let unitsValidReturn = false;
let unitsDimensions: number[] = [];

if(ctx) {
units = this.visit(ctx.u_expr()) as string;
Expand All @@ -1504,19 +1504,19 @@ export class LatexToSympy extends LatexParserVisitor<string | Statement | UnitBl
)}`;
const { dimensions, unitsValid } = checkUnits(units);
if (unitsValid) {
units_dimensions = dimensions;
units_valid = true;
unitsDimensions = dimensions;
unitsValidReturn = true;
} else {
this.addParsingErrorMessage(`Unknown Dimension ${units}`);
units_valid = false;
unitsValidReturn = false;
}
}

return {
units: units,
unitsLatex: unitsLatex,
units_valid: units_valid,
dimensions: units_dimensions,
unitsValid: unitsValidReturn,
dimensions: unitsDimensions,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/parser/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ export type RangeQueryStatement = BaseQueryStatement & {
upperLimitArgument: string;
upperLimitInclusive: boolean;
unitsQueryFunction: string;
input_units: string;
input_units_latex: string;
inputUnits: string;
inputUnitsLatex: string;
outputName: string;
};

Expand Down

0 comments on commit 7d945aa

Please sign in to comment.