#NEWLINE# def _normalize_array( data ) : #NEWLINE# #INDENT# '\n    Coerce buffer data for an AdjustedArray into a standard scalar\n    representation, returning the coerced array and a numpy dtype object to use\n    as a view type when providing public view into the data.\n\n    - float* data is coerced to float64 with viewtype float64.\n    - int32, int64, and uint32 are converted to int64 with viewtype int64.\n    - datetime[*] data is coerced to int64 with a viewtype of datetime64[ns].\n    - bool_ data is coerced to uint8 with a viewtype of bool_.\n\n    Parameters\n    ----------\n    data : np.ndarray\n\n    Returns\n    -------\n    coerced, viewtype : (np.ndarray, np.dtype)\n    ' #NEWLINE# data_dtype = data . dtype #NEWLINE# if ( data_dtype == bool_ ) : #NEWLINE# #INDENT# return ( data . astype ( uint8 ) , dtype ( bool_ ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( data_dtype in FLOAT_DTYPES ) : #NEWLINE# #INDENT# return ( data . astype ( float64 ) , dtype ( float64 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( data_dtype in INT_DTYPES ) : #NEWLINE# #INDENT# return ( data . astype ( int64 ) , dtype ( int64 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if data_dtype . name . startswith ( 'datetime' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# outarray = data . astype ( 'datetime64[ns]' ) . view ( 'int64' ) #NEWLINE# return ( outarray , datetime64ns_dtype ) #NEWLINE# #UNINDENT# except OverflowError : #NEWLINE# #INDENT# raise ValueError ( ( 'AdjustedArray received a datetime array not representable as datetime64[ns].\nMin Date: %s\nMax Date: %s\n' % ( data . min ( ) , data . max ( ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( ( "Don't know how to construct AdjustedArray on data of type %s." % data_dtype ) )