@@ -1079,13 +1079,17 @@ class TestHashTable(object):
1079
1079
1080
1080
def test_lookup_nan (self ):
1081
1081
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 )
1082
1084
m = ht .Float64HashTable ()
1083
1085
m .map_locations (xs )
1084
1086
tm .assert_numpy_array_equal (m .lookup (xs ), np .arange (len (xs ),
1085
1087
dtype = np .int64 ))
1086
1088
1087
1089
def test_lookup_overflow (self ):
1088
1090
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 )
1089
1093
m = ht .UInt64HashTable ()
1090
1094
m .map_locations (xs )
1091
1095
tm .assert_numpy_array_equal (m .lookup (xs ), np .arange (len (xs ),
@@ -1102,6 +1106,8 @@ def test_vector_resize(self):
1102
1106
1103
1107
def _test_vector_resize (htable , uniques , dtype , nvals , safely_resizes ):
1104
1108
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 )
1105
1111
# get_labels may append to uniques
1106
1112
htable .get_labels (vals [:nvals ], uniques , 0 , - 1 )
1107
1113
# to_array() set an external_view_exists flag on uniques.
0 commit comments