<s> """<STR_LIT>""" <EOL> from array import array <EOL> import math <EOL> class Vector2d : <EOL> typecode = '<STR_LIT:d>' <EOL> def __init__ ( self , x , y ) : <EOL> self . x = float ( x ) <EOL> self . y = float ( y ) <EOL> def __iter__ ( self ) : <EOL> return ( i for i in ( self . x , self . y ) ) <EOL> def __repr__ ( self ) : <EOL> class_name = type ( self ) . __name__ <EOL> return '<STR_LIT>' . format ( class_name , * self ) <EOL> def __str__ ( self ) : <EOL> return str ( tuple ( self ) ) <EOL> def __bytes__ ( self ) : <EOL> return bytes ( array ( Vector2d . typecode , self ) ) <EOL> def __eq__ ( self , other ) : <EOL> return tuple ( self ) == tuple ( other ) <EOL> def __abs__ ( self ) : <EOL> return math . hypot ( self . x , self . y ) <EOL> def __bool__ ( self ) : <EOL> return bool ( abs ( self ) ) <EOL> def angle ( self ) : <EOL> return math . atan2 ( self . y , self . x ) <EOL> def __format__ ( self , fmt_spec = '<STR_LIT>' ) : <EOL> if fmt_spec . endswith ( '<STR_LIT:p>' ) : <EOL> fmt_spec = fmt_spec [ : - <NUM_LIT:1> ] <EOL> coords = ( abs ( self ) , self . angle ( ) ) <EOL> outer_fmt = '<STR_LIT>' <EOL> else : <EOL> coords = self <EOL> outer_fmt = '<STR_LIT>' <EOL> components = ( format ( c , fmt_spec ) for c in coords ) <EOL> return outer_fmt . format ( * components ) <EOL> @ classmethod <EOL> def frombytes ( cls , octets ) : <EOL> memv = memoryview ( octets ) . cast ( cls . typecode ) <EOL> return cls ( * memv ) </s>
