#NEWLINE# def rescale( self , units ) : #NEWLINE# #INDENT# '\n        Return a copy of the AnalogSignal(Array) converted to the specified\n        units\n        ' #NEWLINE# to_dims = pq . quantity . validate_dimensionality ( units ) #NEWLINE# if ( self . dimensionality == to_dims ) : #NEWLINE# #INDENT# to_u = self . units #NEWLINE# signal = np . array ( self ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# to_u = pq . Quantity ( 1.0 , to_dims ) #NEWLINE# from_u = pq . Quantity ( 1.0 , self . dimensionality ) #NEWLINE# try : #NEWLINE# #INDENT# cf = pq . quantity . get_conversion_factor ( from_u , to_u ) #NEWLINE# #UNINDENT# except AssertionError : #NEWLINE# #INDENT# raise ValueError ( ( 'Unable to convert between units of "%s"                                  and "%s"' % ( from_u . _dimensionality , to_u . _dimensionality ) ) ) #NEWLINE# #UNINDENT# signal = ( cf * self . magnitude ) #NEWLINE# #UNINDENT# new = self . __class__ ( signal = signal , units = to_u , sampling_rate = self . sampling_rate ) #NEWLINE# new . _copy_data_complement ( self ) #NEWLINE# new . annotations . update ( self . annotations ) #NEWLINE# return new