@@ -277,28 +277,6 @@ def test_factorize_nan(self):
277
277
self .assertTrue (
278
278
np .array_equal (pd .isnull (key ), expected == na_sentinel ))
279
279
280
- def test_vector_resize (self ):
281
- # Test for memory errors after internal vector
282
- # reallocations (pull request #7157)
283
-
284
- def _test_vector_resize (htable , uniques , dtype , nvals ):
285
- vals = np .array (np .random .randn (1000 ), dtype = dtype )
286
- # get_labels appends to the vector
287
- htable .get_labels (vals [:nvals ], uniques , 0 , - 1 )
288
- # to_array resizes the vector
289
- uniques .to_array ()
290
- htable .get_labels (vals , uniques , 0 , - 1 )
291
-
292
- test_cases = [
293
- (hashtable .PyObjectHashTable , hashtable .ObjectVector , 'object' ),
294
- (hashtable .Float64HashTable , hashtable .Float64Vector , 'float64' ),
295
- (hashtable .Int64HashTable , hashtable .Int64Vector , 'int64' )]
296
-
297
- for (tbl , vect , dtype ) in test_cases :
298
- # resizing to empty is a special case
299
- _test_vector_resize (tbl (), vect (), dtype , 0 )
300
- _test_vector_resize (tbl (), vect (), dtype , 10 )
301
-
302
280
def test_complex_sorting (self ):
303
281
# gh 12666 - check no segfault
304
282
# Test not valid numpy versions older than 1.11
@@ -912,6 +890,39 @@ class TestGroupVarFloat32(tm.TestCase, GroupVarTestMixin):
912
890
rtol = 1e-2
913
891
914
892
893
+ class TestHashTable (tm .TestCase ):
894
+
895
+ def test_lookup_nan (self ):
896
+ xs = np .array ([2.718 , 3.14 , np .nan , - 7 , 5 , 2 , 3 ])
897
+ m = hashtable .Float64HashTable ()
898
+ m .map_locations (xs )
899
+ self .assert_numpy_array_equal (m .lookup (xs ),
900
+ np .arange (len (xs ), dtype = np .int64 ))
901
+
902
+ def test_vector_resize (self ):
903
+ # Test for memory errors after internal vector
904
+ # reallocations (pull request #7157)
905
+
906
+ def _test_vector_resize (htable , uniques , dtype , nvals ):
907
+ vals = np .array (np .random .randn (1000 ), dtype = dtype )
908
+ # get_labels appends to the vector
909
+ htable .get_labels (vals [:nvals ], uniques , 0 , - 1 )
910
+ # to_array resizes the vector
911
+ uniques .to_array ()
912
+ htable .get_labels (vals , uniques , 0 , - 1 )
913
+
914
+ test_cases = [
915
+ (hashtable .PyObjectHashTable , hashtable .ObjectVector , 'object' ),
916
+ (hashtable .StringHashTable , hashtable .ObjectVector , 'object' ),
917
+ (hashtable .Float64HashTable , hashtable .Float64Vector , 'float64' ),
918
+ (hashtable .Int64HashTable , hashtable .Int64Vector , 'int64' )]
919
+
920
+ for (tbl , vect , dtype ) in test_cases :
921
+ # resizing to empty is a special case
922
+ _test_vector_resize (tbl (), vect (), dtype , 0 )
923
+ _test_vector_resize (tbl (), vect (), dtype , 10 )
924
+
925
+
915
926
def test_quantile ():
916
927
s = Series (np .random .randn (100 ))
917
928
0 commit comments