4
4
import numpy as np
5
5
import pytest
6
6
7
- from pandas ._config import using_string_dtype
8
-
9
7
from pandas ._libs import (
10
8
algos as libalgos ,
11
9
hashtable as ht ,
@@ -1684,20 +1682,25 @@ def test_unique_complex_numbers(self, array, expected):
1684
1682
1685
1683
1686
1684
class TestHashTable :
1687
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" , strict = False )
1688
1685
@pytest .mark .parametrize (
1689
1686
"htable, data" ,
1690
1687
[
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
+ ),
1693
1696
(ht .Float64HashTable , np .arange (1000 , dtype = np .float64 )),
1694
1697
(ht .Int64HashTable , np .arange (1000 , dtype = np .int64 )),
1695
1698
(ht .UInt64HashTable , np .arange (1000 , dtype = np .uint64 )),
1696
1699
],
1697
1700
)
1698
1701
def test_hashtable_unique (self , htable , data , writable ):
1699
1702
# output of maker has guaranteed unique elements
1700
- s = Series (data )
1703
+ s = Series (data , dtype = data . dtype )
1701
1704
if htable == ht .Float64HashTable :
1702
1705
# add NaN for float column
1703
1706
s .loc [500 ] = np .nan
@@ -1724,20 +1727,25 @@ def test_hashtable_unique(self, htable, data, writable):
1724
1727
reconstr = result_unique [result_inverse ]
1725
1728
tm .assert_numpy_array_equal (reconstr , s_duplicated .values )
1726
1729
1727
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" , strict = False )
1728
1730
@pytest .mark .parametrize (
1729
1731
"htable, data" ,
1730
1732
[
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
+ ),
1733
1741
(ht .Float64HashTable , np .arange (1000 , dtype = np .float64 )),
1734
1742
(ht .Int64HashTable , np .arange (1000 , dtype = np .int64 )),
1735
1743
(ht .UInt64HashTable , np .arange (1000 , dtype = np .uint64 )),
1736
1744
],
1737
1745
)
1738
1746
def test_hashtable_factorize (self , htable , writable , data ):
1739
1747
# output of maker has guaranteed unique elements
1740
- s = Series (data )
1748
+ s = Series (data , dtype = data . dtype )
1741
1749
if htable == ht .Float64HashTable :
1742
1750
# add NaN for float column
1743
1751
s .loc [500 ] = np .nan
0 commit comments