44import numpy as np
55import pytest
66
7- from pandas ._config import using_string_dtype
8-
97from pandas ._libs import (
108 algos as libalgos ,
119 hashtable as ht ,
@@ -1684,20 +1682,25 @@ def test_unique_complex_numbers(self, array, expected):
16841682
16851683
16861684class TestHashTable :
1687- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" , strict = False )
16881685 @pytest .mark .parametrize (
16891686 "htable, data" ,
16901687 [
1691- (ht .PyObjectHashTable , [f"foo_{ i } " for i in range (1000 )]),
1692- (ht .StringHashTable , [f"foo_{ i } " for i in range (1000 )]),
1688+ (
1689+ ht .PyObjectHashTable ,
1690+ np .array ([f"foo_{ i } " for i in range (1000 )], dtype = object ),
1691+ ),
1692+ (
1693+ ht .StringHashTable ,
1694+ np .array ([f"foo_{ i } " for i in range (1000 )], dtype = object ),
1695+ ),
16931696 (ht .Float64HashTable , np .arange (1000 , dtype = np .float64 )),
16941697 (ht .Int64HashTable , np .arange (1000 , dtype = np .int64 )),
16951698 (ht .UInt64HashTable , np .arange (1000 , dtype = np .uint64 )),
16961699 ],
16971700 )
16981701 def test_hashtable_unique (self , htable , data , writable ):
16991702 # output of maker has guaranteed unique elements
1700- s = Series (data )
1703+ s = Series (data , dtype = data . dtype )
17011704 if htable == ht .Float64HashTable :
17021705 # add NaN for float column
17031706 s .loc [500 ] = np .nan
@@ -1724,20 +1727,25 @@ def test_hashtable_unique(self, htable, data, writable):
17241727 reconstr = result_unique [result_inverse ]
17251728 tm .assert_numpy_array_equal (reconstr , s_duplicated .values )
17261729
1727- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" , strict = False )
17281730 @pytest .mark .parametrize (
17291731 "htable, data" ,
17301732 [
1731- (ht .PyObjectHashTable , [f"foo_{ i } " for i in range (1000 )]),
1732- (ht .StringHashTable , [f"foo_{ i } " for i in range (1000 )]),
1733+ (
1734+ ht .PyObjectHashTable ,
1735+ np .array ([f"foo_{ i } " for i in range (1000 )], dtype = object ),
1736+ ),
1737+ (
1738+ ht .StringHashTable ,
1739+ np .array ([f"foo_{ i } " for i in range (1000 )], dtype = object ),
1740+ ),
17331741 (ht .Float64HashTable , np .arange (1000 , dtype = np .float64 )),
17341742 (ht .Int64HashTable , np .arange (1000 , dtype = np .int64 )),
17351743 (ht .UInt64HashTable , np .arange (1000 , dtype = np .uint64 )),
17361744 ],
17371745 )
17381746 def test_hashtable_factorize (self , htable , writable , data ):
17391747 # output of maker has guaranteed unique elements
1740- s = Series (data )
1748+ s = Series (data , dtype = data . dtype )
17411749 if htable == ht .Float64HashTable :
17421750 # add NaN for float column
17431751 s .loc [500 ] = np .nan
0 commit comments