In [1]:
from pycalphad.core.utils import NumPyPrinter
from sympy import Piecewise, lambdify, symbols, Integer,  Pow
from sympy.printing.lambdarepr import LambdaPrinter
import numpy as np
x, y = symbols('x y')

In [2]:
class MyNumPyPrinter(NumPyPrinter):
    def _print_Piecewise(self, expr):
        return LambdaPrinter._print_Piecewise(self, expr)
    def _print_Integer(self, expr):
        # Upcast to work around an integer overflow bug
        return 'asarray({0}, dtype=float)'.format(expr)
p = Piecewise((1/x, y < -1), (Pow(Integer(50), Integer(10e40), evaluate=False), y <= 1), (1/x, True))
lambdify([x, y], p, modules='numpy', printer=NumPyPrinter)(50, 0)


---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-2-eac124b4e66e> in <module>()
      6         return 'asarray({0}, dtype=float)'.format(expr)
      7 p = Piecewise((1/x, y < -1), (Pow(Integer(50), Integer(10e40), evaluate=False), y <= 1), (1/x, True))
----> 8 lambdify([x, y], p, modules='numpy', printer=NumPyPrinter)(50, 0)

/home/rotis/anaconda/envs/calphadpy3/lib/python3.5/site-packages/sympy/utilities/lambdify.py in lambdify(args, expr, modules, printer, use_imps, dummify)
    385     namespace.update({'builtins':builtins, 'range':range})
    386 
--> 387     func = eval(lstr, namespace)
    388     # Apply the docstring
    389     sig = "func({0})".format(", ".join(str(i) for i in names))

KeyboardInterrupt: 

In [ ]:
NumPyPrinter().doprint(p)

In [ ]:
Pow(Integer(50), Integer(10e40), evaluate=False)

In [ ]: