From 5c378ff9ceed411902ccf7f9815a6e0ac27eb335 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 13 Jan 2017 14:18:56 +0800 Subject: [PATCH] Fix sympy->pymbolic interop for Py2 long int (Closes #1) --- pymbolic/interop/sympy.py | 4 ++++ test/test_pymbolic.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/pymbolic/interop/sympy.py b/pymbolic/interop/sympy.py index 0167338..034fb9c 100644 --- a/pymbolic/interop/sympy.py +++ b/pymbolic/interop/sympy.py @@ -85,6 +85,10 @@ class SympyToPymbolicMapper(SympyMapper): def map_ImaginaryUnit(self, expr): # noqa return 1j + # only called for Py2 + def map_long(self, expr): + return long(expr) # noqa + def map_Float(self, expr): # noqa return float(expr) diff --git a/test/test_pymbolic.py b/test/test_pymbolic.py index 9836458..95182c7 100644 --- a/test/test_pymbolic.py +++ b/test/test_pymbolic.py @@ -480,6 +480,13 @@ def test_unifier(): assert match_found(recs, set([(a, b), (b, c), (c, d)])) +def test_long_sympy_mapping(): + from pymbolic.interop.sympy import SympyToPymbolicMapper + import sympy as sp + SympyToPymbolicMapper()(sp.sympify(int(10**20))) + SympyToPymbolicMapper()(sp.sympify(int(10))) + + if __name__ == "__main__": import sys if len(sys.argv) > 1: -- GitLab