@@ -614,10 +614,12 @@ def test_different_unit_comparison(self):
614
614
dt1 = np .dtype ('M8[%s]' % unit1 )
615
615
for unit2 in ['D' , 'h' , 'm' , 's' , 'ms' , 'us' ]:
616
616
dt2 = np .dtype ('M8[%s]' % unit2 )
617
- assert_equal (np .array ('1932-02-17' , dtype = 'M' ).astype (dt1 ),
618
- np .array ('1932-02-17T00:00:00Z' , dtype = 'M' ).astype (dt2 ))
619
- assert_equal (np .array ('10000-04-27' , dtype = 'M' ).astype (dt1 ),
620
- np .array ('10000-04-27T00:00:00Z' , dtype = 'M' ).astype (dt2 ))
617
+ assert_ (np .equal (np .array ('1932-02-17' , dtype = 'M' ).astype (dt1 ),
618
+ np .array ('1932-02-17T00:00:00Z' , dtype = 'M' ).astype (dt2 ),
619
+ casting = 'unsafe' ))
620
+ assert_ (np .equal (np .array ('10000-04-27' , dtype = 'M' ).astype (dt1 ),
621
+ np .array ('10000-04-27T00:00:00Z' , dtype = 'M' ).astype (dt2 ),
622
+ casting = 'unsafe' ))
621
623
622
624
# Shouldn't be able to compare datetime and timedelta
623
625
# TODO: Changing to 'same_kind' or 'safe' casting in the ufuncs by
@@ -732,10 +734,12 @@ def test_datetime_add(self):
732
734
assert_equal ((tda + dta ).dtype , np .dtype ('M8[D]' ))
733
735
734
736
# In M8 + m8, the result goes to higher precision
735
- assert_equal (dta + tdb , dtc )
736
- assert_equal ((dta + tdb ).dtype , np .dtype ('M8[h]' ))
737
- assert_equal (tdb + dta , dtc )
738
- assert_equal ((tdb + dta ).dtype , np .dtype ('M8[h]' ))
737
+ assert_equal (np .add (dta , tdb , casting = 'unsafe' ), dtc )
738
+ assert_equal (np .add (dta , tdb , casting = 'unsafe' ).dtype ,
739
+ np .dtype ('M8[h]' ))
740
+ assert_equal (np .add (tdb , dta , casting = 'unsafe' ), dtc )
741
+ assert_equal (np .add (tdb , dta , casting = 'unsafe' ).dtype ,
742
+ np .dtype ('M8[h]' ))
739
743
740
744
# M8 + M8
741
745
assert_raises (TypeError , np .add , dta , dtb )
@@ -794,14 +798,19 @@ def test_datetime_subtract(self):
794
798
assert_equal ((dtb - tda ).dtype , np .dtype ('M8[D]' ))
795
799
796
800
# In M8 - m8, the result goes to higher precision
797
- assert_equal (dtc - tdb , dte )
798
- assert_equal ((dtc - tdb ).dtype , np .dtype ('M8[h]' ))
801
+ assert_equal (np .subtract (dtc , tdb , casting = 'unsafe' ), dte )
802
+ assert_equal (np .subtract (dtc , tdb , casting = 'unsafe' ).dtype ,
803
+ np .dtype ('M8[h]' ))
799
804
800
805
# M8 - M8 with different goes to higher precision
801
- assert_equal (dtc - dtd , np .timedelta64 (0 ,'h' ))
802
- assert_equal ((dtc - dtd ).dtype , np .dtype ('m8[h]' ))
803
- assert_equal (dtd - dtc , np .timedelta64 (0 ,'h' ))
804
- assert_equal ((dtd - dtc ).dtype , np .dtype ('m8[h]' ))
806
+ assert_equal (np .subtract (dtc , dtd , casting = 'unsafe' ),
807
+ np .timedelta64 (0 ,'h' ))
808
+ assert_equal (np .subtract (dtc , dtd , casting = 'unsafe' ).dtype ,
809
+ np .dtype ('m8[h]' ))
810
+ assert_equal (np .subtract (dtd , dtc , casting = 'unsafe' ),
811
+ np .timedelta64 (0 ,'h' ))
812
+ assert_equal (np .subtract (dtd , dtc , casting = 'unsafe' ).dtype ,
813
+ np .dtype ('m8[h]' ))
805
814
806
815
# m8 - M8
807
816
assert_raises (TypeError , np .subtract , tda , dta )
@@ -915,7 +924,7 @@ def test_datetime_minmax(self):
915
924
916
925
# Interaction with NaT
917
926
a = np .array ('1999-03-12T13Z' , dtype = 'M8[2m]' )
918
- dtnat = np .array ('NaT' , dtype = 'M8[D ]' )
927
+ dtnat = np .array ('NaT' , dtype = 'M8[h ]' )
919
928
assert_equal (np .minimum (a ,dtnat ), a )
920
929
assert_equal (np .minimum (dtnat ,a ), a )
921
930
assert_equal (np .maximum (a ,dtnat ), a )
0 commit comments