#NEWLINE# def test_order( self ) : #NEWLINE# #INDENT# idx1 = DatetimeIndex ( [ '2011-01-01' , '2011-01-02' , '2011-01-03' ] , freq = 'D' , name = 'idx' ) #NEWLINE# idx2 = DatetimeIndex ( [ '2011-01-01 09:00' , '2011-01-01 10:00' , '2011-01-01 11:00' ] , freq = 'H' , tz = 'Asia/Tokyo' , name = 'tzidx' ) #NEWLINE# for idx in [ idx1 , idx2 ] : #NEWLINE# #INDENT# ordered = idx . sort_values ( ) #NEWLINE# self . assert_index_equal ( ordered , idx ) #NEWLINE# self . assertEqual ( ordered . freq , idx . freq ) #NEWLINE# ordered = idx . sort_values ( ascending = False ) #NEWLINE# expected = idx [ : : ( - 1 ) ] #NEWLINE# self . assert_index_equal ( ordered , expected ) #NEWLINE# self . assertEqual ( ordered . freq , expected . freq ) #NEWLINE# self . assertEqual ( ordered . freq . n , ( - 1 ) ) #NEWLINE# ( ordered , indexer ) = idx . sort_values ( return_indexer = True ) #NEWLINE# self . assert_index_equal ( ordered , idx ) #NEWLINE# self . assert_numpy_array_equal ( indexer , np . array ( [ 0 , 1 , 2 ] ) ) #NEWLINE# self . assertEqual ( ordered . freq , idx . freq ) #NEWLINE# ( ordered , indexer ) = idx . sort_values ( return_indexer = True , ascending = False ) #NEWLINE# expected = idx [ : : ( - 1 ) ] #NEWLINE# self . assert_index_equal ( ordered , expected ) #NEWLINE# self . assert_numpy_array_equal ( indexer , np . array ( [ 2 , 1 , 0 ] ) ) #NEWLINE# self . assertEqual ( ordered . freq , expected . freq ) #NEWLINE# self . assertEqual ( ordered . freq . n , ( - 1 ) ) #NEWLINE# #UNINDENT# idx1 = DatetimeIndex ( [ '2011-01-01' , '2011-01-03' , '2011-01-05' , '2011-01-02' , '2011-01-01' ] , name = 'idx1' ) #NEWLINE# exp1 = DatetimeIndex ( [ '2011-01-01' , '2011-01-01' , '2011-01-02' , '2011-01-03' , '2011-01-05' ] , name = 'idx1' ) #NEWLINE# idx2 = DatetimeIndex ( [ '2011-01-01' , '2011-01-03' , '2011-01-05' , '2011-01-02' , '2011-01-01' ] , tz = 'Asia/Tokyo' , name = 'idx2' ) #NEWLINE# for ( idx , expected ) in [ ( idx1 , idx ) , ( idx1 , exp1 ) , ( idx1 , exp1 ) ] : #NEWLINE# #INDENT# ordered = idx . sort_values ( ) #NEWLINE# self . assert_index_equal ( ordered , expected ) #NEWLINE# self . assertIsNone ( ordered . freq ) #NEWLINE# ordered = idx . sort_values ( ascending = False ) #NEWLINE# self . assert_index_equal ( ordered , expected [ : : ( - 1 ) ] ) #NEWLINE# self . assertIsNone ( ordered . freq ) #NEWLINE# ( ordered , indexer ) = idx . sort_values ( return_indexer = True ) #NEWLINE# self . assert_index_equal ( ordered , expected ) #NEWLINE# self . assert_numpy_array_equal ( indexer , np . array ( [ 0 , 4 , 3 , 1 , 2 ] ) ) #NEWLINE# self . assertIsNone ( ordered . freq ) #NEWLINE# ( ordered , indexer ) = idx . sort_values ( return_indexer = True , ascending = False ) #NEWLINE# self . assert_index_equal ( ordered , expected [ : : ( - 1 ) ] ) #NEWLINE# self . assert_numpy_array_equal ( indexer , np . array ( [ 2 , 1 , 3 , 4 , 0 ] ) ) #NEWLINE# self . assertIsNone ( ordered . freq )