Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"argument is not an mpz" while loading dill-ed SymPy expressions. #12202

Closed
musically-ut opened this issue Feb 20, 2017 · 2 comments
Closed

"argument is not an mpz" while loading dill-ed SymPy expressions. #12202

musically-ut opened this issue Feb 20, 2017 · 2 comments

Comments

@musically-ut
Copy link

This is probably related to #2724.

The .dill file which causes this for me is here.

I see the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-39-155386c49816> in <module>()
----> 1 read_soln(3, 4)

<ipython-input-34-a5139f00b443> in read_soln(N, M)
      2 def read_soln(N, M):
      3     with open(f_name_templ.format(N, M), 'rb') as f:
----> 4         data = dill.load(f)
      5         print('Successfully read ({},{}).'.format(N, M))
      6         return data

/home/utkarshu/miniconda3/lib/python3.5/site-packages/dill/dill.py in load(file)
    248     pik = Unpickler(file)
    249     pik._main = _main_module
--> 250     obj = pik.load()
    251     if type(obj).__module__ == _main_module.__name__: # point obj class to main
    252         try: obj.__class__ == getattr(pik._main, type(obj).__name__)

/home/utkarshu/miniconda3/lib/python3.5/pickle.py in load(self)
   1037                     raise EOFError
   1038                 assert isinstance(key, bytes_types)
-> 1039                 dispatch[key[0]](self)
   1040         except _Stop as stopinst:
   1041             return stopinst.value

/home/utkarshu/miniconda3/lib/python3.5/pickle.py in load_reduce(self)
   1392         args = stack.pop()
   1393         func = stack[-1]
-> 1394         stack[-1] = func(*args)
   1395     dispatch[REDUCE[0]] = load_reduce
   1396 

/home/utkarshu/miniconda3/lib/python3.5/site-packages/sympy/core/operations.py in __new__(cls, *args, **options)
     39             return args[0]
     40 
---> 41         c_part, nc_part, order_symbols = cls.flatten(args)
     42         is_commutative = not nc_part
     43         obj = cls._from_args(c_part + nc_part, is_commutative)

/home/utkarshu/miniconda3/lib/python3.5/site-packages/sympy/core/add.py in flatten(cls, seq)
    132                     return [S.NaN], [], None
    133                 if coeff.is_Number:
--> 134                     coeff += o
    135                     if coeff is S.NaN:
    136                         # we know for sure the result will be nan

/home/utkarshu/miniconda3/lib/python3.5/site-packages/sympy/core/numbers.py in __add__(self, other)
   1787         elif isinstance(other, Integer):
   1788             return Integer(self.p + other.p)
-> 1789         return Rational.__add__(self, other)
   1790 
   1791     def __radd__(self, other):

/home/utkarshu/miniconda3/lib/python3.5/site-packages/sympy/core/decorators.py in __sympifyit_wrapper(a, b)
     75                 if not hasattr(b, '_op_priority'):
     76                     b = sympify(b, strict=True)
---> 77                 return func(a, b)
     78             except SympifyError:
     79                 return retval

/home/utkarshu/miniconda3/lib/python3.5/site-packages/sympy/core/numbers.py in __add__(self, other)
   1374             return Rational(self.p*other.q + self.q*other.p, self.q*other.q)
   1375         elif isinstance(other, Float):
-> 1376             return other + self
   1377         else:
   1378             return Number.__add__(self, other)

/home/utkarshu/miniconda3/lib/python3.5/site-packages/sympy/core/decorators.py in __sympifyit_wrapper(a, b)
     75                 if not hasattr(b, '_op_priority'):
     76                     b = sympify(b, strict=True)
---> 77                 return func(a, b)
     78             except SympifyError:
     79                 return retval

/home/utkarshu/miniconda3/lib/python3.5/site-packages/sympy/core/numbers.py in __add__(self, other)
    928         if isinstance(other, Number):
    929             rhs, prec = other._as_mpf_op(self._prec)
--> 930             return Float._new(mlib.mpf_add(self._mpf_, rhs, prec, rnd), prec)
    931         return Number.__add__(self, other)
    932 

/home/utkarshu/miniconda3/lib/python3.5/site-packages/mpmath/libmp/libmpf.py in mpf_add(s, t, prec, rnd, _sub)
    766         return t
    767     if sman:
--> 768         return normalize1(ssign, sman, sexp, sbc, prec or sbc, rnd)
    769     return s
    770 

TypeError: argument is not an mpz

I am using Python 3.5.2 with dill version 0.2.5 and sympy version 1.0.

@oscarbenjamin
Copy link
Collaborator

Is this still a problem? Can you show how to reproduce this?

@musically-ut
Copy link
Author

Okay, just tried this with the .dill file I had linked to and it worked with:

In [4]: sympy.__version__
Out[4]: '1.3'

In [5]: dill.__version__
Out[5]: '0.2.8.2'

Hence, I will close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants