pytexit icon indicating copy to clipboard operation
pytexit copied to clipboard

Issue #59 Nested subtraction order of operations

Open abuyukyi101198 opened this issue 3 years ago • 4 comments

Hi, Issue #59 shows that nested subtraction operations have their parentheses removed, which results in the output being a different formula.

I added a special condition for nested subtractions, encasing them in parentheses in visit_BinOp().

This process adds some redundant parentheses, which I removed by two regex substitutions in simplify(). They still don't remove outermost parentheses, so I added a TODO for that.

abuyukyi101198 avatar Jul 29 '22 13:07 abuyukyi101198

Thanks for fixing this. As it's a hotfix, can you mention this PR as comment in the code so future developers can quickly understand why we did this?

erwanp avatar Jul 29 '22 17:07 erwanp

Added the comments but I have no idea why the checks failed this time.

abuyukyi101198 avatar Jul 29 '22 19:07 abuyukyi101198

Alright, I got why the builds are failing.

They still don't remove outermost parentheses, so I added a TODO for that.

That's why. Finding a way of adding an exception to the special condition added so that the outermost subtraction is not encased in parentheses should fix everything. Wouldn't be a hotfix then, I guess.

abuyukyi101198 avatar Jul 29 '22 19:07 abuyukyi101198

Try if you can. Else, you can also adjust the hard-coded test to match the new output (assuming it's mathematically correct of course!)

You'll also need to add a new text corresponding to #59 to make sure any future change never breaks your use case.

And then we'll be able to merge

erwanp avatar Jul 30 '22 09:07 erwanp