On Thu, Apr 2, 2009 at 8:04 PM, ARMAND BRUMER <bru...@fordham.edu> wrote:
> Dera William,
>
> Thanks for the detailed answer. Unfortunately, I am dealing with collections
> of many tens of thousands of "curves". I was able to load them into sage
> with
>
> load /Users/armandbrumer/sage/TORNOTSS6short.sage
>
> I want to  reverse the process after using sage to modify the lists, for
> instance by using liu's program.
>
> If I understand you properly, there is no simple analogous command to save
> my list of lists in text format.  So, what I need can  be done only by
> changing the data to strings and then saving those strings...


I'm still not sure what you're asking, but if you want to save objects
(in a binary compressed format), in Sage you can save almost any data
structure to disk, and load it back.  For this, the situation
regarding this is *VASTLY BETTER* in Sage than it is in Magma.   The
command that does this is simply called "save".  Here are some
examples:

            sage: a = matrix(2, [1,2,3,-5/2])
            sage: save(a, 'test.sobj')
            sage: load('test.sobj')
            [   1    2]
            [   3 -5/2]

Here's an example involving starting with the curves of conductor up
to 100 in Cremona, saving the list of them, loading it back into a new
session, changing something about one, saving the list again, then
loading that back and verifying that the change was saved:

sage: E = list(cremona_curves([1..100]))
sage: len(E)
306
sage: save(E, 'E.sobj')
sage:
Exiting SAGE (CPU time 0m1.48s, Wall time 1m0.36s).
D-69-91-159-158:tmp wstein$ sage
----------------------------------------------------------------------
| Sage Version 3.4, Release Date: 2009-03-11                         |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: E = load('E.sobj')
sage: len(E)
306
sage: E[0].armand = 'brumer'
sage: save(E, 'E.sobj')
sage:
Exiting SAGE (CPU time 0m0.32s, Wall time 0m17.92s).
D-69-91-159-158:tmp wstein$ sage
----------------------------------------------------------------------
| Sage Version 3.4, Release Date: 2009-03-11                         |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: E = load('E.sobj')
sage: E[0].armand
'brumer'


When it comes to lists of lists, here is an example both of saving to
an sobj (compressed binary format) and saving to plain text:

sage: E = list(cremona_curves([1..100]))
sage: v = [e.a_invariants() for e in E]
sage: v[:3]
[[0, -1, 1, -10, -20], [0, -1, 1, -7820, -263580], [0, -1, 1, 0, 0]]
sage: save(v,'v.sobj')
sage: len(load('v.sobj'))
306
sage: open('v.txt','w').write(str(v))
sage: open('v.txt').read()[:300]
'[[0, -1, 1, -10, -20], [0, -1, 1, -7820, -263580], [0, -1, 1, 0, 0],
[1, 0, 1, 4, -6], [1, 0, 1, -36, -70], [1, 0, 1, -171, -874], [1, 0,
1, -1, 0], [1, 0, 1, -2731, -55146], [1, 0, 1, -11, 12], [1, 1, 1,
-10, -10], [1, 1, 1, -135, -660], [1, 1, 1, -5, 2], [1, 1, 1, 35,
-28], [1, 1, 1, -2160, -39540'
sage: vv = sage_eval(open('v.txt').read())
sage: vv == v
True

William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to