kpeeters / cadabra2

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

Odd output from cadabra2python #164

Closed leo-brewin closed 4 years ago

leo-brewin commented 4 years ago

Running cadabra2python over the following code

      {a,b,c}::Indices(position=independent).
      substitute (foo, $A->B$)

produces the following output

   __cdbtmp__ = Indices(Ex(r'''{a,b,c}'''), Ex(r'''position=independent)''') )
   substitute (foo, Ex(r'''A->B''', False))
  1. Is the trailing bracket in position=independent) required?
  2. Is the False argument to Ex required?
  3. Is it safe to delete both the stray bracket and the False argument?
kpeeters commented 4 years ago

That weird closing bracket was definitely a bug in the pre-parser; interestingly this then prevented another bug from ever being triggered, and the property parser fortunately was nice enough to let this pass. Now all fixed on github/master.

The second one is safe to delete, but won't do any harm. At some point in the past it was necessary to inform python about Ex objects which go out of scope immediately, but this is no longer necessary and the 2nd parameter is in fact ignored.

leo-brewin commented 4 years ago

Thanks for the update. I'm inclined to rewrite parts of the tutorial to not suggest that people edit the output of cadabra2python. That will avoid these issues. Though I might still include a copy of the output in the tutorial just for the readers reference.

leo-brewin commented 4 years ago

Sorry I messed up with the GitHub buttons :).