On Mar 3, 4:46 am, Jason Grout <[email protected]> wrote:
> You are missing a closing bracket and comma at the end of this line
> (i.e., "],").  The number looks a little smaller as well.  Was something
> chopped off?
>
> Jason

Oh man, that's what's happening.  When I print another failing string
from mathematica, the original string looks fine, but the replace()d
version is munged:
8.553921460041636*^-14 - 0.034517073945669455*I,
6.438460875557439*^-13 - 0.2507643434931489*I,
becomes
8.553921460041636e-14 - 0.0 6.438460875557439e-13 -
0.2507643434931489*I,
And of course, when I try to sage_eval the latter, it fails.  So this
seems to be a problem with replace().

This all happens inside a loop, and doesn't happen when I try it out
of that loop (except with really long inputs, so the code to reproduce
it isn't as simple as I would have liked.

First, download http://www.physics.usyd.edu.au/~felix/sage/res.m
Save the file somewhere.
Then run:
sage: mathematica('SetDirectory["/path/to/file"]')
sage: mathematica("<< res.m")
sage: res = mathematica('res')
sage: for i in range(84):
....:     resel_s = repr(res[i+1][1]).replace('{','[').replace
('}',']').replace('*^','e').replace('\n',' ')
....:     resel = sage_eval(resel_s)
....:
------------------------------------------------------------
   File "<string>", line 1
     [[-RealNumber('0.9018796952509034') + RealNumber
('0.9018804701526122')*I,
<SNIP>
SyntaxError: invalid syntax

Run the loop three times in the same sage session, and on the third
time you'll get the error occurring in a different place in the loop.
Weird!

Any ideas?

Many thanks,
Felix
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to