<s> from . . ndtypes import Float64 , make_array_type <EOL> from seq_expr import SeqExpr <EOL> class ArrayExpr ( SeqExpr ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , array , type = None , source_info = None ) : <EOL> self . array = array <EOL> self . type = type <EOL> self . source_info = source_info <EOL> def children ( self ) : <EOL> yield self . array <EOL> class Array ( ArrayExpr ) : <EOL> def __init__ ( self , elts , type = None , source_info = None ) : <EOL> self . elts = tuple ( elts ) <EOL> self . type = type <EOL> self . source_info = source_info <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % "<STR_LIT:U+002CU+0020>" . join ( str ( e ) for e in self . elts ) <EOL> def children ( self ) : <EOL> return self . elts <EOL> def __hash__ ( self ) : <EOL> return hash ( self . elts ) <EOL> class Slice ( ArrayExpr ) : <EOL> def __init__ ( self , start , stop , step , type = None , source_info = None ) : <EOL> self . start = start <EOL> self . stop = stop <EOL> self . step = step <EOL> self . type = type <EOL> self . source_info = source_info <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . start . short_str ( ) , <EOL> self . stop . short_str ( ) , <EOL> self . step . short_str ( ) ) <EOL> def __repr__ ( self ) : <EOL> return str ( self ) <EOL> def children ( self ) : <EOL> yield self . start <EOL> yield self . stop <EOL> yield self . step <EOL> def __eq__ ( self , other ) : <EOL> return other . __class__ is Slice and other . start == self . start and other . stop == self . stop and other . step == self . step <EOL> def __hash__ ( self ) : <EOL> return hash ( ( self . start , self . stop , self . step ) ) <EOL> class ConstArray ( ArrayExpr ) : <EOL> def __init__ ( self , shape , value , type = None , source_info = None ) : <EOL> self . shape = shape <EOL> self . value = value <EOL> self . type = type <EOL> self . source_info = source_info <EOL> def children ( self ) : <EOL> yield self . shape <EOL> yield self . value <EOL> class DiagonalArray ( ArrayExpr ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , shape , value , offset = None , type = None , source_info = None ) : <EOL> self . shape = shape <EOL> self . value = value <EOL> self . offset = offset <EOL> self . type = type <EOL> self . source_info = source_info <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . shape , self . value , self . offset ) <EOL> def children ( self ) : <EOL> yield self . shape <EOL> yield self . value <EOL> if self . offset is not None : <EOL> yield self . offset <EOL> class ExtractDiagonal ( ArrayExpr ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class ConstArrayLike ( ArrayExpr ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , array , value , type = None , source_info = None ) : <EOL> self . array = array <EOL> self . value = value <EOL> self . type = type <EOL> self . source_info = source_info <EOL> def children ( self ) : <EOL> yield self . array <EOL> yield self . value <EOL> class Range ( ArrayExpr ) : <EOL> def __init__ ( self , start , stop , step , type = None , source_info = None ) : <EOL> self . start = start <EOL> self . stop = stop <EOL> self . step = step <EOL> self . type = type <EOL> self . source_info = source_info <EOL> def children ( self ) : <EOL> yield self . start <EOL> yield self . stop <EOL> yield self . step <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . start , self . stop , self . step ) <EOL> class AllocArray ( ArrayExpr ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , shape , elt_type , type = None , order = "<STR_LIT:C>" , source_info = None ) : <EOL> self . shape = shape <EOL> self . elt_type = elt_type <EOL> self . type = type <EOL> self . source_info = source_info <EOL> assert order == "<STR_LIT:C>" , "<STR_LIT>" % order <EOL> self . order = order <EOL> def children ( self ) : <EOL> yield self . shape <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . shape , self . elt_type ) <EOL> class ArrayView ( ArrayExpr ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , data , shape , strides , offset , size , type = None , source_info = None ) : <EOL> self . data = data <EOL> self . shape = shape <EOL> self . strides = strides <EOL> self . offset = offset <EOL> self . size = size <EOL> self . type = type <EOL> self . source_info = source_info <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . data , self . shape , self . strides , self . offset , self . size ) <EOL> def children ( self ) : <EOL> yield self . data <EOL> yield self . shape <EOL> yield self . strides <EOL> yield self . offset <EOL> yield self . size <EOL> class Ravel ( ArrayExpr ) : <EOL> def children ( self ) : <EOL> return ( self . array , ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % self . array <EOL> class Reshape ( ArrayExpr ) : <EOL> def __init__ ( self , array , shape , type = None , source_info = None ) : <EOL> self . array = array <EOL> self . shape = shape <EOL> self . type = type <EOL> self . source_info = source_info <EOL> def children ( self ) : <EOL> yield self . array <EOL> yield self . shape <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . array , self . shape ) <EOL> class Shape ( ArrayExpr ) : <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % self . array <EOL> class Strides ( ArrayExpr ) : <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % self . array <EOL> class Transpose ( ArrayExpr ) : <EOL> def children ( self ) : <EOL> yield self . array <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % self . array <EOL> class Tile ( ArrayExpr ) : <EOL> def __init__ ( self , array , reps , type = None , source_info = None ) : <EOL> self . array = array <EOL> self . reps = reps <EOL> self . type = type <EOL> self . source_info = source_info <EOL> def children ( self ) : <EOL> yield self . array <EOL> yield self . reps <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . array , self . reps ) <EOL> class Where ( ArrayExpr ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , array ) : <EOL> self . array = array <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % self . array <EOL> def children ( self ) : <EOL> yield self . array <EOL> class Compress ( ArrayExpr ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , condition , data ) : <EOL> self . condition = condition <EOL> self . data = data <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . condition , self . data ) <EOL> def children ( self ) : <EOL> yield self . data <EOL> yield self . data </s>
