def test_local_zero_div():
 for t in (T.scalar, T.ivector, T.ftensor4):
  x = t('x')
  for op in (T.int_div, T.true_div):
   y = op(0, x)
   g = optimize(FunctionGraph([x], [y]))
   divs = [node for node in g.toposort() if (isinstance(node.op, T.elemwise.Elemwise) and isinstance(node.op.scalar_op, type(op.scalar_op)))]
   assert (len(divs) == 0)
   output = g.outputs[0]
   assert (output.ndim == y.ndim)
   assert (output.type == y.type)
   assert (theano.tensor.get_scalar_constant_value(output) == 0)

def test_local_zero_div ( ) : for t in ( T . scalar , T . ivector , T . ftensor4 ) : x = t ( 'x' ) for op in ( T . int_div , T . true_div ) : y = op ( 0 , x ) g = optimize ( FunctionGraph ( [ x ] , [ y ] ) ) divs = [ node for node in g . toposort ( ) if ( isinstance ( node . op , T . elemwise . Elemwise ) and isinstance ( node . op . scalar_op , type ( op . scalar_op ) ) ) ] assert ( len ( divs ) == 0 ) output = g . outputs [ 0 ] assert ( output . ndim == y . ndim ) assert ( output . type == y . type ) assert ( theano . tensor . get_scalar_constant_value ( output ) == 0 )
tests 0/x -> 0 .