Something is still not quite right though, look at this for example:
In [1]: from sympy import Matrix, symbols, __version__
In [2]: from numpy import array, load
In [3]: __version__
Out[3]: '0.6.3'
In [4]: m = array(Matrix([1,2,3])).astype('d')
In [5]: m
Out[5]:
array([[ 1.],
[ 2.],
[ 3.]])
In [6]: m.dump('spam.dat')
In [7]: M = load('spam.dat') # no problems here
In [8]: M
Out[8]:
array([[ 1.],
[ 2.],
[ 3.]])
In [9]: m = array(Matrix([1,2,3])).astype('object')
In [10]: m.dump('spam.dat')
In [11]: M = load('spam.dat') # problem here
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/williamh/<ipython console> in <module>()
/usr/lib/python2.5/site-packages/numpy/core/numeric.pyc in load(file)
609 if isinstance(file, type("")):
610 file = _file(file,"rb")
--> 611 return _cload(file)
612
613 # Adapted from matplotlib
TypeError: __new__() takes exactly 2 arguments (1 given)
Looks like the problem arises when the numpy array contains 'objects',
right? However, if I construct a 'clean' NumPy array containing
'objects', I get different behaviour:
In [16]: m = array([1,2,3]).astype('object') # no sympy Matrix here
In [17]: m.dump('spam.dat')
In [18]: M = load('spam.dat') # and no problem here
In [20]: numpy.__version__
Out[20]: '1.0.4'
Something probably (obviously?) goes astray during the conversion from
sympy.Matrix -> numpy.array. Perhaps a symbol to string conversion?
Dunno.
Regards,
William
2008/11/25 Ondrej Certik <[EMAIL PROTECTED]>:
>
> On Tue, Nov 25, 2008 at 11:32 AM, William Hunter <[EMAIL PROTECTED]> wrote:
>>
>> Hmmm, I was too hasty, this doesn't happen under 0.6.3 (which I
>> thought I had).
>
> No problem. Btw, if you know how to solve the pickling problem with
> protocol 2, it'd be really cool. I have no idea so far:
>
> http://code.google.com/p/sympy/issues/detail?id=1177
>
> Thanks,
> Ondrej
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sympy" group.
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/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---