#NEWLINE# def __getitem__( self , args ) : #NEWLINE# #INDENT# if ( isinstance ( args , list ) and any ( [ isinstance ( a , slice ) for a in args ] ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not isinstance ( args , tuple ) ) : #NEWLINE# #INDENT# args = ( args , ) #NEWLINE# #UNINDENT# #UNINDENT# args = theano . tensor . subtensor . make_constant ( args ) #NEWLINE# advanced = False #NEWLINE# axis = None #NEWLINE# for ( i , arg ) in enumerate ( args ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( arg is not numpy . newaxis ) : #NEWLINE# #INDENT# theano . tensor . subtensor . Subtensor . convert ( arg ) #NEWLINE# #UNINDENT# #UNINDENT# except theano . tensor . subtensor . AdvancedIndexingError : #NEWLINE# #INDENT# if advanced : #NEWLINE# #INDENT# axis = None #NEWLINE# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# advanced = True #NEWLINE# axis = i #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if advanced : #NEWLINE# #INDENT# if ( ( axis is not None ) and all ( ( ( isinstance ( a , slice ) and equal_slices ( a , slice ( None ) ) ) for a in args [ : axis ] ) ) and all ( ( ( isinstance ( a , slice ) and equal_slices ( a , slice ( None ) ) ) for a in args [ ( axis + 1 ) : ] ) ) and isinstance ( args [ axis ] , ( numpy . ndarray , list , TensorVariable , TensorConstant , theano . tensor . sharedvar . TensorSharedVariable ) ) ) : #NEWLINE# #INDENT# return self . take ( args [ axis ] , axis ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return theano . tensor . subtensor . advanced_subtensor ( self , * args ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( numpy . newaxis in args ) : #NEWLINE# #INDENT# counter = 0 #NEWLINE# pattern = [ ] #NEWLINE# new_args = [ ] #NEWLINE# for arg in args : #NEWLINE# #INDENT# if ( arg == numpy . newaxis ) : #NEWLINE# #INDENT# pattern . append ( 'x' ) #NEWLINE# new_args . append ( slice ( None , None , None ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pattern . append ( counter ) #NEWLINE# counter += 1 #NEWLINE# new_args . append ( arg ) #NEWLINE# #UNINDENT# #UNINDENT# view = self . dimshuffle ( pattern ) #NEWLINE# rval = view . __getitem__ ( tuple ( new_args ) ) #NEWLINE# return rval #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return theano . tensor . subtensor . Subtensor ( args ) ( self , * theano . tensor . subtensor . Subtensor . collapse ( pattern , ( lambda entry : isinstance ( entry , Variable ) ) ) )