You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, in order to save large amounts of high-precision data,
I need to serialize mpmath numbers. Unfortunately, this fails with an
exception I don't understand, since the method **getstate** seems to be
defined (see below). Converting to and from strings is only a temporary
option, because it is way too slow and wastes space.Example:In [2]:import mpmathIn [3]:a = mpmath.mpc(1+2j)In [4]:a
Out[4]:mpc(real='1.0', imag='2.0')In [5]:import pickleIn [6]:pickle.dumps(a)Results in:<type 'exceptions.TypeError'>: a class that defines **slots** without
defining **getstate** cannot be pickled What version of the product are you using? On what operating system? Python 2.5
mpmath 0.7
on opensuse 10.2
This bug has been fixed in svn.If you don't want to install the svn version, you can make your copy of 0.7 work by
adding the following methods to the mpf class in mptypes.py:```
def __getstate__(self): return self._mpf_
def __setstate__(self, val): self._mpf_ = val
```And the following to the mpc class:```
def __getstate__(self): return self._mpc_
def __setstate__(self, val): self._mpc_ = val
```
Original issue for #74: http://code.google.com/p/mpmath/issues/detail?id=34
Original author: https://code.google.com/u/109204080795773808200/
The text was updated successfully, but these errors were encountered: