Skip to content

Commit f9019fe

Browse files
committed
Add tests for readonly memoryviews
1 parent 9c820f3 commit f9019fe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pandas/tests/test_algos.py

+6
Original file line numberDiff line numberDiff line change
@@ -1079,13 +1079,17 @@ class TestHashTable(object):
10791079

10801080
def test_lookup_nan(self):
10811081
xs = np.array([2.718, 3.14, np.nan, -7, 5, 2, 3])
1082+
# GH 21688 ensure we can deal with readonly memory views
1083+
xs.setflags(write=False)
10821084
m = ht.Float64HashTable()
10831085
m.map_locations(xs)
10841086
tm.assert_numpy_array_equal(m.lookup(xs), np.arange(len(xs),
10851087
dtype=np.int64))
10861088

10871089
def test_lookup_overflow(self):
10881090
xs = np.array([1, 2, 2**63], dtype=np.uint64)
1091+
# GH 21688 ensure we can deal with readonly memory views
1092+
xs.setflags(write=False)
10891093
m = ht.UInt64HashTable()
10901094
m.map_locations(xs)
10911095
tm.assert_numpy_array_equal(m.lookup(xs), np.arange(len(xs),
@@ -1102,6 +1106,8 @@ def test_vector_resize(self):
11021106

11031107
def _test_vector_resize(htable, uniques, dtype, nvals, safely_resizes):
11041108
vals = np.array(np.random.randn(1000), dtype=dtype)
1109+
# GH 21688 ensure we can deal with readonly memory views
1110+
vals.setflags(write=False)
11051111
# get_labels may append to uniques
11061112
htable.get_labels(vals[:nvals], uniques, 0, -1)
11071113
# to_array() set an external_view_exists flag on uniques.

0 commit comments

Comments
 (0)