MCPcopy Create free account
hub / github.com/apache/arrow / test_dictionary_encode_sliced

Function test_dictionary_encode_sliced

python/pyarrow/tests/test_array.py:2210–2239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2208
2209
2210def test_dictionary_encode_sliced():
2211 cases = [
2212 (pa.array([1, 2, 3, None, 1, 2, 3])[1:-1],
2213 pa.DictionaryArray.from_arrays(
2214 pa.array([0, 1, None, 2, 0], type='int32'),
2215 [2, 3, 1])),
2216 (pa.array([None, 'foo', 'bar', 'foo', 'xyzzy'])[1:-1],
2217 pa.DictionaryArray.from_arrays(
2218 pa.array([0, 1, 0], type='int32'),
2219 ['foo', 'bar'])),
2220 (pa.array([None, 'foo', 'bar', 'foo', 'xyzzy'],
2221 type=pa.large_string())[1:-1],
2222 pa.DictionaryArray.from_arrays(
2223 pa.array([0, 1, 0], type='int32'),
2224 pa.array(['foo', 'bar'], type=pa.large_string()))),
2225 ]
2226 for arr, expected in cases:
2227 result = arr.dictionary_encode()
2228 assert result.equals(expected)
2229 result = pa.chunked_array([arr]).dictionary_encode()
2230 assert result.num_chunks == 1
2231 assert result.type == expected.type
2232 assert result.chunk(0).equals(expected)
2233 result = pa.chunked_array([], type=arr.type).dictionary_encode()
2234 assert result.num_chunks == 0
2235 assert result.type == expected.type
2236
2237 # ARROW-9143 dictionary_encode after slice was segfaulting
2238 array = pa.array(['foo', 'bar', 'baz'])
2239 array.slice(1).dictionary_encode()
2240
2241
2242def test_dictionary_encode_zero_length():

Callers

nothing calls this directly

Calls 4

equalsMethod · 0.80
chunked_arrayMethod · 0.80
arrayMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected