kpeeters / cadabra2

A field-theory motivated approach to computer algebra.
https://cadabra.science/
GNU General Public License v3.0
223 stars 37 forks source link

Python interface: string representation eats up the whitespace in indices #47

Closed hershsingh closed 7 years ago

hershsingh commented 7 years ago

I am using cadabra from within python, that is

> from cadabra2 import *

Looks like the string representation of the Ex objects gobbles up the spaces in indices. For example,

> ex = Ex(r'A^{i j}') 
> print(ex.__repr__())

gives me something like

{A}  (0x2243ee8)
  1:^{i}  (0x2243f38)
  2:^{j}  (0x2247de8)

as it should. But if I then pass str(ex) to Ex,

> print(Ex(str(ex)).__repr__())

I get

{A}  (0x224d608)
  1:^{ij}  (0x224d658)

I would have expected the result to be same as before.

I am using version 2.1.4 compiled from source.

kpeeters commented 7 years ago

I have just pushed a fix for this to github. Please check and let me know.

hershsingh commented 7 years ago

Wow, that was quick! It works now. Thanks!

kpeeters commented 7 years ago

It was a single line which I commented out at some point (for reasons long forgotten) and just had to be put back in again ;-) Anyway, thanks for raising the issue.