def PatternOptimizer(p1, p2, ign=True): return gof.OpKeyOptimizer(gof.PatternSub(p1, p2), ignore_newtrees=ign)
from theano import config, gof from six import iteritems from theano.compile.io import In, Out from theano.compile import function from theano.compile import UnusedInputError from theano.gof import MissingInputError from theano.compat import exc_message from theano.tests.unittest_tools import SkipTest from theano import tensor from theano import tensor as T import theano import numpy as N PatternOptimizer = lambda p1, p2, ign=True: gof.OpKeyOptimizer( gof.PatternSub(p1, p2), ignore_newtrees=ign) def checkfor(testcase, fn, E): try: fn() except Exception as e: if isinstance(e, E): # we got the exception we wanted return else: # we did not get the exception we wanted raise # fn worked, but it shouldn't have testcase.fail()