Skip to content

Commit e0b7098

Browse files
committed
Test writable arrays with parameters
1 parent 9deaf07 commit e0b7098

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pandas/tests/test_algos.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -1077,19 +1077,21 @@ class TestGroupVarFloat32(GroupVarTestMixin):
10771077

10781078
class TestHashTable(object):
10791079

1080-
def test_lookup_nan(self):
1080+
@pytest.mark.parametrize('writable', [True, False])
1081+
def test_lookup_nan(self, writable):
10811082
xs = np.array([2.718, 3.14, np.nan, -7, 5, 2, 3])
10821083
# GH 21688 ensure we can deal with readonly memory views
1083-
xs.setflags(write=False)
1084+
xs.setflags(write=writable)
10841085
m = ht.Float64HashTable()
10851086
m.map_locations(xs)
10861087
tm.assert_numpy_array_equal(m.lookup(xs), np.arange(len(xs),
10871088
dtype=np.int64))
10881089

1089-
def test_lookup_overflow(self):
1090+
@pytest.mark.parametrize('writable', [True, False])
1091+
def test_lookup_overflow(self, writable):
10901092
xs = np.array([1, 2, 2**63], dtype=np.uint64)
10911093
# GH 21688 ensure we can deal with readonly memory views
1092-
xs.setflags(write=False)
1094+
xs.setflags(write=writable)
10931095
m = ht.UInt64HashTable()
10941096
m.map_locations(xs)
10951097
tm.assert_numpy_array_equal(m.lookup(xs), np.arange(len(xs),
@@ -1100,14 +1102,15 @@ def test_get_unique(self):
11001102
exp = np.array([1, 2, 2**63], dtype=np.uint64)
11011103
tm.assert_numpy_array_equal(s.unique(), exp)
11021104

1103-
def test_vector_resize(self):
1105+
@pytest.mark.parametrize('writable', [True, False])
1106+
def test_vector_resize(self, writable):
11041107
# Test for memory errors after internal vector
11051108
# reallocations (pull request #7157)
11061109

11071110
def _test_vector_resize(htable, uniques, dtype, nvals, safely_resizes):
11081111
vals = np.array(np.random.randn(1000), dtype=dtype)
11091112
# GH 21688 ensure we can deal with readonly memory views
1110-
vals.setflags(write=False)
1113+
vals.setflags(write=writable)
11111114
# get_labels may append to uniques
11121115
htable.get_labels(vals[:nvals], uniques, 0, -1)
11131116
# to_array() set an external_view_exists flag on uniques.

0 commit comments

Comments
 (0)