#NEWLINE# def test_timedelta64_operations_with_integers( self ) : #NEWLINE# #INDENT# startdate = Series ( date_range ( '2013-01-01' , '2013-01-03' ) ) #NEWLINE# enddate = Series ( date_range ( '2013-03-01' , '2013-03-03' ) ) #NEWLINE# s1 = ( enddate - startdate ) #NEWLINE# s1 [ 2 ] = np . nan #NEWLINE# s2 = Series ( [ 2 , 3 , 4 ] ) #NEWLINE# expected = Series ( ( s1 . values . astype ( np . int64 ) / s2 ) , dtype = 'm8[ns]' ) #NEWLINE# expected [ 2 ] = np . nan #NEWLINE# result = ( s1 / s2 ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# s2 = Series ( [ 20 , 30 , 40 ] ) #NEWLINE# expected = Series ( ( s1 . values . astype ( np . int64 ) / s2 ) , dtype = 'm8[ns]' ) #NEWLINE# expected [ 2 ] = np . nan #NEWLINE# result = ( s1 / s2 ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# result = ( s1 / 2 ) #NEWLINE# expected = Series ( ( s1 . values . astype ( np . int64 ) / 2 ) , dtype = 'm8[ns]' ) #NEWLINE# expected [ 2 ] = np . nan #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# s2 = Series ( [ 20 , 30 , 40 ] ) #NEWLINE# expected = Series ( ( s1 . values . astype ( np . int64 ) * s2 ) , dtype = 'm8[ns]' ) #NEWLINE# expected [ 2 ] = np . nan #NEWLINE# result = ( s1 * s2 ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# for dtype in [ 'int32' , 'int16' , 'uint32' , 'uint64' , 'uint32' , 'uint16' , 'uint8' ] : #NEWLINE# #INDENT# s2 = Series ( [ 20 , 30 , 40 ] , dtype = dtype ) #NEWLINE# expected = Series ( ( s1 . values . astype ( np . int64 ) * s2 . astype ( np . int64 ) ) , dtype = 'm8[ns]' ) #NEWLINE# expected [ 2 ] = np . nan #NEWLINE# result = ( s1 * s2 ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# #UNINDENT# result = ( s1 * 2 ) #NEWLINE# expected = Series ( ( s1 . values . astype ( np . int64 ) * 2 ) , dtype = 'm8[ns]' ) #NEWLINE# expected [ 2 ] = np . nan #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# result = ( s1 * ( - 1 ) ) #NEWLINE# expected = Series ( ( s1 . values . astype ( np . int64 ) * ( - 1 ) ) , dtype = 'm8[ns]' ) #NEWLINE# expected [ 2 ] = np . nan #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# assert_series_equal ( ( s1 / s2 . astype ( float ) ) , Series ( [ Timedelta ( '2 days 22:48:00' ) , Timedelta ( '1 days 23:12:00' ) , Timedelta ( 'NaT' ) ] ) ) #NEWLINE# assert_series_equal ( ( s1 / 2.0 ) , Series ( [ Timedelta ( '29 days 12:00:00' ) , Timedelta ( '29 days 12:00:00' ) , Timedelta ( 'NaT' ) ] ) ) #NEWLINE# for op in [ '__add__' , '__sub__' ] : #NEWLINE# #INDENT# sop = getattr ( s1 , op , None ) #NEWLINE# if ( sop is not None ) : #NEWLINE# #INDENT# self . assertRaises ( TypeError , sop , 1 ) #NEWLINE# self . assertRaises ( TypeError , sop , s2 . values )