#NEWLINE# def test_subtraction_ops_with_tz( self ) : #NEWLINE# #INDENT# dti = date_range ( '20130101' , periods = 3 ) #NEWLINE# ts = Timestamp ( '20130101' ) #NEWLINE# dt = ts . to_datetime ( ) #NEWLINE# dti_tz = date_range ( '20130101' , periods = 3 ) . tz_localize ( 'US/Eastern' ) #NEWLINE# ts_tz = Timestamp ( '20130101' ) . tz_localize ( 'US/Eastern' ) #NEWLINE# ts_tz2 = Timestamp ( '20130101' ) . tz_localize ( 'CET' ) #NEWLINE# dt_tz = ts_tz . to_datetime ( ) #NEWLINE# td = Timedelta ( '1 days' ) #NEWLINE# def _check( result , expected ) : #NEWLINE# #INDENT# self . assertEqual ( result , expected ) #NEWLINE# self . assertIsInstance ( result , Timedelta ) #NEWLINE# #UNINDENT# result = ( ts - ts ) #NEWLINE# expected = Timedelta ( '0 days' ) #NEWLINE# _check ( result , expected ) #NEWLINE# result = ( dt_tz - ts_tz ) #NEWLINE# expected = Timedelta ( '0 days' ) #NEWLINE# _check ( result , expected ) #NEWLINE# result = ( ts_tz - dt_tz ) #NEWLINE# expected = Timedelta ( '0 days' ) #NEWLINE# _check ( result , expected ) #NEWLINE# self . assertRaises ( TypeError , ( lambda : ( dt_tz - ts ) ) ) #NEWLINE# self . assertRaises ( TypeError , ( lambda : ( dt_tz - dt ) ) ) #NEWLINE# self . assertRaises ( TypeError , ( lambda : ( dt_tz - ts_tz2 ) ) ) #NEWLINE# self . assertRaises ( TypeError , ( lambda : ( dt - dt_tz ) ) ) #NEWLINE# self . assertRaises ( TypeError , ( lambda : ( ts - dt_tz ) ) ) #NEWLINE# self . assertRaises ( TypeError , ( lambda : ( ts_tz2 - ts ) ) ) #NEWLINE# self . assertRaises ( TypeError , ( lambda : ( ts_tz2 - dt ) ) ) #NEWLINE# self . assertRaises ( TypeError , ( lambda : ( ts_tz - ts_tz2 ) ) ) #NEWLINE# self . assertRaises ( TypeError , ( lambda : ( dti - ts_tz ) ) ) #NEWLINE# self . assertRaises ( TypeError , ( lambda : ( dti_tz - ts ) ) ) #NEWLINE# self . assertRaises ( TypeError , ( lambda : ( dti_tz - ts_tz2 ) ) ) #NEWLINE# result = ( dti_tz - dt_tz ) #NEWLINE# expected = TimedeltaIndex ( [ '0 days' , '1 days' , '2 days' ] ) #NEWLINE# tm . assert_index_equal ( result , expected ) #NEWLINE# result = ( dt_tz - dti_tz ) #NEWLINE# expected = TimedeltaIndex ( [ '0 days' , '-1 days' , '-2 days' ] ) #NEWLINE# tm . assert_index_equal ( result , expected ) #NEWLINE# result = ( dti_tz - ts_tz ) #NEWLINE# expected = TimedeltaIndex ( [ '0 days' , '1 days' , '2 days' ] ) #NEWLINE# tm . assert_index_equal ( result , expected ) #NEWLINE# result = ( ts_tz - dti_tz ) #NEWLINE# expected = TimedeltaIndex ( [ '0 days' , '-1 days' , '-2 days' ] ) #NEWLINE# tm . assert_index_equal ( result , expected ) #NEWLINE# result = ( td - td ) #NEWLINE# expected = Timedelta ( '0 days' ) #NEWLINE# _check ( result , expected ) #NEWLINE# result = ( dti_tz - td ) #NEWLINE# expected = DatetimeIndex ( [ '20121231' , '20130101' , '20130102' ] , tz = 'US/Eastern' ) #NEWLINE# tm . assert_index_equal ( result , expected )