pytexit icon indicating copy to clipboard operation
pytexit copied to clipboard

simplify_fractions doesn't work

Open turner-eng opened this issue 5 years ago • 4 comments

print(py2tex('theta = w_k * a ** 4 / t ** 4 / E',simplify_fractions=True)) prints out:

$$\theta=\frac{\frac{w_k a^4}{t^4}}{E}$$

instead of:

$$\theta=\frac{w_k a^4}{t^4E}$$

turner-eng avatar Jan 06 '21 17:01 turner-eng

Thank you for spotting it !

I think that simplify_fractions could only deal with small decimals and write them as function, i.e. turn 0.5 to 1/2. The "simplify_fraction" may be a little misleading. @alexhagen can you confirm ?

It would be a nice featur e!!

erwanp avatar Jan 06 '21 18:01 erwanp

I'll look further into this on the weekend, but simplify_fractions uses looks_like_int on both the denominator and numerator to check if it can be simplified - and doesn't simplify if both the numerator and denominator don't "look like integers". So at first blush, that looks like expected behavior - I'll verify that. This could be a feature request, however.

alexhagen avatar Jan 07 '21 15:01 alexhagen

This is a very handy feature, looking forwards to see it been added!

turner-eng avatar Jan 31 '21 03:01 turner-eng

All, I've opened a fork and a new feature branch to add this in. My plan is to use sympy to do the simplification.

alexhagen avatar Jan 31 '21 18:01 alexhagen