#NEWLINE# def test_grad_inrange( ) : #NEWLINE# #INDENT# for bound_definition in [ ( True , True ) , ( False , False ) ] : #NEWLINE# #INDENT# op = InRange ( * bound_definition ) #NEWLINE# x = theano . tensor . fscalar ( 'x' ) #NEWLINE# low = theano . tensor . fscalar ( 'low' ) #NEWLINE# high = theano . tensor . fscalar ( 'high' ) #NEWLINE# out = op ( x , low , high ) #NEWLINE# ( gx , glow , ghigh ) = theano . tensor . grad ( out , [ x , low , f ] ) #NEWLINE# f = theano . function ( [ x , low , high ] , [ gx , glow , ghigh ] ) #NEWLINE# utt . assert_allclose ( f ( 0 , 1 , 5 ) , [ 0 , 0 , 0 ] ) #NEWLINE# utt . assert_allclose ( f ( 1 , 1 , 5 ) , [ 0 , 0 , 0 ] ) #NEWLINE# utt . assert_allclose ( f ( 2 , 1 , 5 ) , [ 0 , 0 , 0 ] ) #NEWLINE# utt . assert_allclose ( f ( 5 , 1 , 5 ) , [ 0 , 0 , 0 ] ) #NEWLINE# utt . assert_allclose ( f ( 7 , 1 , 5 ) , [ 0 , 0 , 0 ] )