erwanp / pytexit

Convert a Python expression to a LaTeX formula
https://pytexit.readthedocs.io/
Other
114 stars 31 forks source link

Treatment of pow(x,2) => x^2 (etc.) #53

Closed mm002a closed 2 years ago

mm002a commented 2 years ago

First, thanks for all the work which has gone into developing this tool. It is a great idea and I am hoping to use it quite a bit.

I have run the test under spyder and there seem to been a few changes which are not reflected in the "Expected results." These ARE trivial e.g. extra braces "{}" in the tex; a "\left( \right )" replacing a "( )"- obviously not real problems.

One feature request, please. Please can we get "pow(x,2)" to map to "$$x^2$$". The expression "power(x,2)" transforms into "$$x^2$$". I assume that is line 665 of core.py. I don't understand the python function power( ). To my shame, I have never done any serious object oriented programming, so I got lost in the coding of core.py This would be great.

Sorry, I cannot offer a proper fix, Chris Thompson

erwanp commented 2 years ago

Hello @mm002a , actually was already implemented : https://github.com/erwanp/pytexit/blob/master/pytexit/core/core.py#L251 by @emetor in https://github.com/erwanp/pytexit/pull/44

I'll release a new version soon so you can enjoy it !

erwanp commented 2 years ago

Done in https://github.com/erwanp/pytexit/releases/tag/0.4.0 , please confirm it works

mm002a commented 2 years ago

Wow, thanks very much indeed. I'll give you more feedback as I gain experience, if that would be helpful. I think of Jupyter as an aid to reproducible computing and this is a REAL step forward. Chris Thompson

On Sun, 10 Apr 2022, 20:11 Erwan Pannier, @.***> wrote:

Hello @mm002a https://github.com/mm002a , actually was already implemented : https://github.com/erwanp/pytexit/blob/master/pytexit/core/core.py#L251 by @emetor https://github.com/emetor in #44 https://github.com/erwanp/pytexit/pull/44

I'll release a new version soon so you can enjoy it !

— Reply to this email directly, view it on GitHub https://github.com/erwanp/pytexit/issues/53#issuecomment-1094350989, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGPFPO7Z5BR7ORQOIUDV3TTVEMRWNANCNFSM5S745AFQ . You are receiving this because you were mentioned.Message ID: @.***>

mm002a commented 2 years ago

I started with <y=pow(x,2)> and just kept adding terms....

I eventually constructed this example: py2tex( "y=3g(beta)+13.2math.log(pow(x,1+alpha5/2)+0.5gamma_1)pow(D,1.5)/E_PE+piD**2/4- arctan(0.25)" ,simplify_fractions=True) It works fine. GREAT JOB.

All the intermediate expressions were also correct.

OK, we could discuss why we do not get <D^{3/2}> but I prefer your current treatment - it corresponds to my python input (not what I should have used!).

erwanp commented 2 years ago

Great it works. You should thank @emetor who implemented it