@@ -975,10 +975,10 @@ def test_get_indexer(self):
975
975
idx2 = Index ([2 , 4 , 6 ])
976
976
977
977
r1 = idx1 .get_indexer (idx2 )
978
- assert_almost_equal (r1 , np .array ([1 , 3 , - 1 ]))
978
+ assert_almost_equal (r1 , np .array ([1 , 3 , - 1 ], dtype = np . intp ))
979
979
980
980
r1 = idx2 .get_indexer (idx1 , method = 'pad' )
981
- e1 = np .array ([- 1 , 0 , 0 , 1 , 1 ])
981
+ e1 = np .array ([- 1 , 0 , 0 , 1 , 1 ], dtype = np . intp )
982
982
assert_almost_equal (r1 , e1 )
983
983
984
984
r2 = idx2 .get_indexer (idx1 [::- 1 ], method = 'pad' )
@@ -988,7 +988,7 @@ def test_get_indexer(self):
988
988
assert_almost_equal (r1 , rffill1 )
989
989
990
990
r1 = idx2 .get_indexer (idx1 , method = 'backfill' )
991
- e1 = np .array ([0 , 0 , 1 , 1 , 2 ])
991
+ e1 = np .array ([0 , 0 , 1 , 1 , 2 ], dtype = np . intp )
992
992
assert_almost_equal (r1 , e1 )
993
993
994
994
rbfill1 = idx2 .get_indexer (idx1 , method = 'bfill' )
@@ -1013,25 +1013,30 @@ def test_get_indexer_nearest(self):
1013
1013
all_methods = ['pad' , 'backfill' , 'nearest' ]
1014
1014
for method in all_methods :
1015
1015
actual = idx .get_indexer ([0 , 5 , 9 ], method = method )
1016
- tm .assert_numpy_array_equal (actual , np .array ([0 , 5 , 9 ]))
1016
+ tm .assert_numpy_array_equal (actual , np .array ([0 , 5 , 9 ],
1017
+ dtype = np .intp ))
1017
1018
1018
1019
actual = idx .get_indexer ([0 , 5 , 9 ], method = method , tolerance = 0 )
1019
- tm .assert_numpy_array_equal (actual , np .array ([0 , 5 , 9 ]))
1020
+ tm .assert_numpy_array_equal (actual , np .array ([0 , 5 , 9 ],
1021
+ dtype = np .intp ))
1020
1022
1021
1023
for method , expected in zip (all_methods , [[0 , 1 , 8 ], [1 , 2 , 9 ],
1022
1024
[0 , 2 , 9 ]]):
1023
1025
actual = idx .get_indexer ([0.2 , 1.8 , 8.5 ], method = method )
1024
- tm .assert_numpy_array_equal (actual , np .array (expected ))
1026
+ tm .assert_numpy_array_equal (actual , np .array (expected ,
1027
+ dtype = np .intp ))
1025
1028
1026
1029
actual = idx .get_indexer ([0.2 , 1.8 , 8.5 ], method = method ,
1027
1030
tolerance = 1 )
1028
- tm .assert_numpy_array_equal (actual , np .array (expected ))
1031
+ tm .assert_numpy_array_equal (actual , np .array (expected ,
1032
+ dtype = np .intp ))
1029
1033
1030
1034
for method , expected in zip (all_methods , [[0 , - 1 , - 1 ], [- 1 , 2 , - 1 ],
1031
1035
[0 , 2 , - 1 ]]):
1032
1036
actual = idx .get_indexer ([0.2 , 1.8 , 8.5 ], method = method ,
1033
1037
tolerance = 0.2 )
1034
- tm .assert_numpy_array_equal (actual , np .array (expected ))
1038
+ tm .assert_numpy_array_equal (actual , np .array (expected ,
1039
+ dtype = np .intp ))
1035
1040
1036
1041
with tm .assertRaisesRegexp (ValueError , 'limit argument' ):
1037
1042
idx .get_indexer ([1 , 0 ], method = 'nearest' , limit = 1 )
@@ -1042,22 +1047,24 @@ def test_get_indexer_nearest_decreasing(self):
1042
1047
all_methods = ['pad' , 'backfill' , 'nearest' ]
1043
1048
for method in all_methods :
1044
1049
actual = idx .get_indexer ([0 , 5 , 9 ], method = method )
1045
- tm .assert_numpy_array_equal (actual , np .array ([9 , 4 , 0 ]))
1050
+ tm .assert_numpy_array_equal (actual , np .array ([9 , 4 , 0 ],
1051
+ dtype = np .intp ))
1046
1052
1047
1053
for method , expected in zip (all_methods , [[8 , 7 , 0 ], [9 , 8 , 1 ],
1048
1054
[9 , 7 , 0 ]]):
1049
1055
actual = idx .get_indexer ([0.2 , 1.8 , 8.5 ], method = method )
1050
- tm .assert_numpy_array_equal (actual , np .array (expected ))
1056
+ tm .assert_numpy_array_equal (actual , np .array (expected ,
1057
+ dtype = np .intp ))
1051
1058
1052
1059
def test_get_indexer_strings (self ):
1053
1060
idx = pd .Index (['b' , 'c' ])
1054
1061
1055
1062
actual = idx .get_indexer (['a' , 'b' , 'c' , 'd' ], method = 'pad' )
1056
- expected = np .array ([- 1 , 0 , 1 , 1 ])
1063
+ expected = np .array ([- 1 , 0 , 1 , 1 ], dtype = np . intp )
1057
1064
tm .assert_numpy_array_equal (actual , expected )
1058
1065
1059
1066
actual = idx .get_indexer (['a' , 'b' , 'c' , 'd' ], method = 'backfill' )
1060
- expected = np .array ([0 , 0 , 1 , - 1 ])
1067
+ expected = np .array ([0 , 0 , 1 , - 1 ], dtype = np . intp )
1061
1068
tm .assert_numpy_array_equal (actual , expected )
1062
1069
1063
1070
with tm .assertRaises (TypeError ):
0 commit comments