| 1099 | |
| 1100 | |
| 1101 | def test_dictionary_from_arrays_boundscheck(): |
| 1102 | indices1 = pa.array([0, 1, 2, 0, 1, 2]) |
| 1103 | indices2 = pa.array([0, -1, 2]) |
| 1104 | indices3 = pa.array([0, 1, 2, 3]) |
| 1105 | |
| 1106 | dictionary = pa.array(['foo', 'bar', 'baz']) |
| 1107 | |
| 1108 | # Works fine |
| 1109 | pa.DictionaryArray.from_arrays(indices1, dictionary) |
| 1110 | |
| 1111 | with pytest.raises(pa.ArrowException): |
| 1112 | pa.DictionaryArray.from_arrays(indices2, dictionary) |
| 1113 | |
| 1114 | with pytest.raises(pa.ArrowException): |
| 1115 | pa.DictionaryArray.from_arrays(indices3, dictionary) |
| 1116 | |
| 1117 | # If we are confident that the indices are "safe" we can pass safe=False to |
| 1118 | # disable the boundschecking |
| 1119 | pa.DictionaryArray.from_arrays(indices2, dictionary, safe=False) |
| 1120 | |
| 1121 | |
| 1122 | def test_dictionary_indices(): |