#NEWLINE# def test_ufunc_coercions( self ) : #NEWLINE# #INDENT# idx = date_range ( '2011-01-01' , periods = 3 , freq = '2D' , name = 'x' ) #NEWLINE# delta = np . timedelta64 ( 1 , 'D' ) #NEWLINE# for result in [ ( idx + delta ) , np . add ( idx , delta ) ] : #NEWLINE# #INDENT# tm . assertIsInstance ( result , DatetimeIndex ) #NEWLINE# exp = date_range ( '2011-01-02' , periods = 3 , freq = '2D' , name = 'x' ) #NEWLINE# tm . assert_index_equal ( result , exp ) #NEWLINE# self . assertEqual ( result . freq , '2D' ) #NEWLINE# #UNINDENT# for result in [ ( idx - delta ) , np . subtract ( idx , delta ) ] : #NEWLINE# #INDENT# tm . assertIsInstance ( result , DatetimeIndex ) #NEWLINE# exp = date_range ( '2010-12-31' , periods = 3 , freq = '2D' , name = 'x' ) #NEWLINE# tm . assert_index_equal ( result , exp ) #NEWLINE# self . assertEqual ( result . freq , '2D' ) #NEWLINE# #UNINDENT# delta = np . array ( [ np . timedelta64 ( 1 , 'D' ) , np . timedelta64 ( 2 , 'D' ) , np . timedelta64 ( 3 , 'D' ) ] ) #NEWLINE# for result in [ ( idx + delta ) , np . add ( idx , delta ) ] : #NEWLINE# #INDENT# tm . assertIsInstance ( result , DatetimeIndex ) #NEWLINE# exp = DatetimeIndex ( [ '2011-01-02' , '2011-01-05' , '2011-01-08' ] , freq = '3D' , name = 'x' ) #NEWLINE# tm . assert_index_equal ( result , exp ) #NEWLINE# self . assertEqual ( result . freq , '3D' ) #NEWLINE# #UNINDENT# for result in [ ( idx - delta ) , np . subtract ( idx , delta ) ] : #NEWLINE# #INDENT# tm . assertIsInstance ( result , DatetimeIndex ) #NEWLINE# exp = DatetimeIndex ( [ '2010-12-31' , '2011-01-01' , '2011-01-02' ] , freq = 'D' , name = 'x' ) #NEWLINE# tm . assert_index_equal ( result , exp ) #NEWLINE# self . assertEqual ( exp . freq , 'D' )