<s> import numpy <EOL> import theano <EOL> from theano import Op , Apply <EOL> from theano . tensor import TensorType <EOL> from theano . gof . type import CDataType <EOL> from nose . plugins . skip import SkipTest <EOL> class ProdOp ( Op ) : <EOL> __props__ = ( ) <EOL> def make_node ( self , i ) : <EOL> return Apply ( self , [ i ] , [ CDataType ( '<STR_LIT>' , '<STR_LIT>' ) ( ) ] ) <EOL> def c_support_code ( self ) : <EOL> return """<STR_LIT>""" <EOL> def c_code ( self , node , name , inps , outs , sub ) : <EOL> return """<STR_LIT>""" % dict ( out = outs [ <NUM_LIT:0> ] , inp = inps [ <NUM_LIT:0> ] ) <EOL> def c_code_cache_version ( self ) : <EOL> return ( <NUM_LIT:0> , ) <EOL> class GetOp ( Op ) : <EOL> __props__ = ( ) <EOL> def make_node ( self , c ) : <EOL> return Apply ( self , [ c ] , [ TensorType ( '<STR_LIT>' , ( False , ) ) ( ) ] ) <EOL> def c_support_code ( self ) : <EOL> return """<STR_LIT>""" <EOL> def c_code ( self , node , name , inps , outs , sub ) : <EOL> return """<STR_LIT>""" % dict ( out = outs [ <NUM_LIT:0> ] , inp = inps [ <NUM_LIT:0> ] ) <EOL> def c_code_cache_version ( self ) : <EOL> return ( <NUM_LIT:0> , ) <EOL> def test_cdata ( ) : <EOL> if not theano . config . cxx : <EOL> raise SkipTest ( "<STR_LIT>" ) <EOL> i = TensorType ( '<STR_LIT>' , ( False , ) ) ( ) <EOL> c = ProdOp ( ) ( i ) <EOL> i2 = GetOp ( ) ( c ) <EOL> mode = None <EOL> if theano . config . mode == "<STR_LIT>" : <EOL> mode = "<STR_LIT>" <EOL> f = theano . function ( [ i ] , i2 , mode = mode ) <EOL> v = numpy . random . randn ( <NUM_LIT:9> ) . astype ( '<STR_LIT>' ) <EOL> v2 = f ( v ) <EOL> assert ( v2 == v ) . all ( ) </s>
