[Numpy-discussion] save a matrix
Charles R Harris
charlesr.harris at gmail.com
Fri Dec 1 00:12:03 EST 2006
On 11/30/06, Keith Goodman <kwgoodman at gmail.com> wrote:
>
> What's a good way to save matrix objects to file for later use? I just
> need something quick for debugging.
>
> I saw two suggestions on this list from Francesc Altet (2006-05-22):
>
> 1. Use tofile and fromfile and save the meta data yourself.
>
> 2. pytables
>
> Any suggestions for #3?
Is this what you want?
In [14]: a
Out[14]:
matrix([[2, 3],
[4, 5]])
In [15]: b
Out[15]:
matrix([[2, 3],
[4, 5]])
In [16]: f = open('dump.pkl','w')
In [17]: pickle.dump(a,f)
In [18]: pickle.dump(b,f)
In [19]: f.close()
In [20]: f = open('dump.pkl','r')
In [21]: x = pickle.load(f)
In [22]: y = pickle.load(f)
In [23]: f.close()
In [24]: x
Out[24]:
matrix([[2, 3],
[4, 5]])
In [25]: y
Out[25]:
matrix([[2, 3],
[4, 5]])
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20061130/cbd8fb11/attachment.html>
More information about the NumPy-Discussion
mailing list