Closed pixelzoom closed 2 years ago
This is still occurring very occassionally as of 8/2/2021.
I haven't seen this in a long while. It's not blocking, and will not cause problems in practice.
Based on the error message: adjacent divide should have been collapsed: [[x]/3]/1
...
The failing assertion is in HelpfulEquationNode.ts, the Node that is shown in the Equation screen, with the bottom (equation) drawer open, and "simplify" checkbox unchecked.
assert && assert( !previousOperator || previousOperator !== FBSymbols.DIVIDE,
`adjacent divide should have been collapsed: ${equation.toString()}` );
To reproduce:
/ 3
+ 1
/ 1
, as shown below+ 0
, and the assertion will failIn practice (assertions disabled) the screenshot below is what is shown.
So what should be shown? The ground truth for the "helpful" format is document in equation-formats.md.
Based on this rule:
(1) Adjacent addition and subtraction operations are collapsed, e.g.:
+ 3 - 2 → x + 1
. If they collapse to zero, then the operations are dropped entirely, e.g.:* 2 + 3 - 3 → 2x
The + 0
in / 3 + 0 / 1
should be dropped, resulting in / 3 / 1
. Then based on this rule:
(6) Adjacent division operations are collapsed, e.g.:
/ 3 / 2 → x/6
... / 3 / 1
should be collapsed to / 3
.
So what is displayed should be y = x / 3
.
The fix for this needs to be applied in the constructor of HelpfulEquation.js, where we're currently doing nothing for the if ( currentOperand === 0 )
case.
if ( currentOperator === FBSymbols.PLUS || currentOperator === FBSymbols.MINUS ) {
if ( currentOperand === 0 ) {
// ignore plus or minus zero
}
In HelpfulEquation.js, lne 113 is likely the buggy line:
if ( stack.length > 0 ) {
previousFunction = stack[ stack.length - 1 ];
113 previousOperator = currentOperator;
previousOperand = previousFunction.operandProperty.get();
}
It should have been:
113 previousOperator = previousFunction.operator;
Fixed in the above commit. Screenshot:
To verify in 1.2.0-rc.1, you'll need to compare its behavior to 1.0.25 (the published version).
y = x/3
in 1.2.0-rc.1, but y = x / 3 / 1
in 1.0.25.If you have questions about whether the format is correct, see equation-formats.md or ask me.
In my testing, the unsimplified equations look the same in 1.2.0-rc.1 and 1.2.25 except in the instances mentioned in the above https://github.com/phetsims/function-builder/issues/135#issuecomment-1139067805. The unsimplified equations are following the format outlined in https://github.com/phetsims/function-builder/blob/master/doc/equation-formats.md.
Closing but will reopen if something comes up.
This happened for the first time on 1/18/2021, 8:45:48 PM. It's either a new issue introduced by common-code changes, or (more likely) something that is unlikely to be exercised by CT. Note that a specific equation (
[[x]/3]/1
) is shown in the assertion message, so I would start by trying to manually reproduce that equation.