@@ -657,7 +657,7 @@ def test_on_specialized_type(self):
657
657
# GH13936
658
658
for dtype in [np .uint8 , np .uint16 , np .uint32 , np .uint64 ,
659
659
np .int8 , np .int16 , np .int32 , np .int64 ,
660
- np .float32 , np .float64 ]:
660
+ np .float16 , np . float32 , np .float64 ]:
661
661
df1 = pd .DataFrame ({
662
662
'value' : [5 , 2 , 25 , 100 , 78 , 120 , 79 ],
663
663
'symbol' : list ("ABCDEFG" )},
@@ -672,22 +672,26 @@ def test_on_specialized_type(self):
672
672
673
673
df1 = df1 .sort_values ('value' ).reset_index (drop = True )
674
674
675
- result = pd .merge_asof (df1 , df2 , on = 'value' )
675
+ if dtype == np .float16 :
676
+ with self .assertRaises (MergeError ):
677
+ pd .merge_asof (df1 , df2 , on = 'value' )
678
+ else :
679
+ result = pd .merge_asof (df1 , df2 , on = 'value' )
676
680
677
- expected = pd .DataFrame ({
678
- 'symbol' : list ("BACEGDF" ),
679
- 'value' : [2 , 5 , 25 , 78 , 79 , 100 , 120 ],
680
- 'result' : list ('xxxxxyz' )},
681
- columns = ['symbol' , 'value' , 'result' ])
682
- expected .value = dtype (expected .value )
681
+ expected = pd .DataFrame ({
682
+ 'symbol' : list ("BACEGDF" ),
683
+ 'value' : [2 , 5 , 25 , 78 , 79 , 100 , 120 ],
684
+ 'result' : list ('xxxxxyz' )},
685
+ columns = ['symbol' , 'value' , 'result' ])
686
+ expected .value = dtype (expected .value )
683
687
684
- assert_frame_equal (result , expected )
688
+ assert_frame_equal (result , expected )
685
689
686
690
def test_on_specialized_type_by_int (self ):
687
691
# GH13936
688
692
for dtype in [np .uint8 , np .uint16 , np .uint32 , np .uint64 ,
689
693
np .int8 , np .int16 , np .int32 , np .int64 ,
690
- np .float32 , np .float64 ]:
694
+ np .float16 , np . float32 , np .float64 ]:
691
695
df1 = pd .DataFrame ({
692
696
'value' : [5 , 2 , 25 , 100 , 78 , 120 , 79 ],
693
697
'key' : [1 , 2 , 3 , 2 , 3 , 1 , 2 ],
@@ -704,17 +708,21 @@ def test_on_specialized_type_by_int(self):
704
708
705
709
df1 = df1 .sort_values ('value' ).reset_index (drop = True )
706
710
707
- result = pd .merge_asof (df1 , df2 , on = 'value' , by = 'key' )
708
-
709
- expected = pd .DataFrame ({
710
- 'symbol' : list ("BACEGDF" ),
711
- 'key' : [2 , 1 , 3 , 3 , 2 , 2 , 1 ],
712
- 'value' : [2 , 5 , 25 , 78 , 79 , 100 , 120 ],
713
- 'result' : [np .nan , 'x' , np .nan , np .nan , np .nan , 'y' , 'x' ]},
714
- columns = ['symbol' , 'key' , 'value' , 'result' ])
715
- expected .value = dtype (expected .value )
716
-
717
- assert_frame_equal (result , expected )
711
+ if dtype == np .float16 :
712
+ with self .assertRaises (MergeError ):
713
+ pd .merge_asof (df1 , df2 , on = 'value' , by = 'key' )
714
+ else :
715
+ result = pd .merge_asof (df1 , df2 , on = 'value' , by = 'key' )
716
+
717
+ expected = pd .DataFrame ({
718
+ 'symbol' : list ("BACEGDF" ),
719
+ 'key' : [2 , 1 , 3 , 3 , 2 , 2 , 1 ],
720
+ 'value' : [2 , 5 , 25 , 78 , 79 , 100 , 120 ],
721
+ 'result' : [np .nan , 'x' , np .nan , np .nan , np .nan , 'y' , 'x' ]},
722
+ columns = ['symbol' , 'key' , 'value' , 'result' ])
723
+ expected .value = dtype (expected .value )
724
+
725
+ assert_frame_equal (result , expected )
718
726
719
727
def test_on_float_by_int (self ):
720
728
# type specialize both "by" and "on" parameters
0 commit comments