Skip to content

Commit 7cd9cff

Browse files
avm19avm19
authored andcommitted
Modify an existing test to cover the issue with na_pos > 128.
1 parent 2030d9d commit 7cd9cff

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pandas/tests/libs/test_hashtable.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,19 @@ def test_map_locations(self, table_type, dtype, writable):
149149
def test_map_locations_mask(self, table_type, dtype, writable):
150150
if table_type == ht.PyObjectHashTable:
151151
pytest.skip("Mask not supported for object")
152-
N = 3
152+
N = 129 # must be > 128 to test GH#58924
153153
table = table_type(uses_mask=True)
154154
keys = (np.arange(N) + N).astype(dtype)
155155
keys.flags.writeable = writable
156-
table.map_locations(keys, np.array([False, False, True]))
156+
mask = np.concatenate([np.repeat(False, N - 1), [True]], axis=0)
157+
table.map_locations(keys, mask)
157158
for i in range(N - 1):
158159
assert table.get_item(keys[i]) == i
159160

160161
with pytest.raises(KeyError, match=re.escape(str(keys[N - 1]))):
161162
table.get_item(keys[N - 1])
162163

163-
assert table.get_na() == 2
164+
assert table.get_na() == N - 1
164165

165166
def test_lookup(self, table_type, dtype, writable):
166167
N = 3

0 commit comments

Comments
 (0)