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

Function test_dictionary_encode_simple

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

Source from the content-addressed store, hash-verified

2182
2183
2184def test_dictionary_encode_simple():
2185 cases = [
2186 (pa.array([1, 2, 3, None, 1, 2, 3]),
2187 pa.DictionaryArray.from_arrays(
2188 pa.array([0, 1, 2, None, 0, 1, 2], type='int32'),
2189 [1, 2, 3])),
2190 (pa.array(['foo', None, 'bar', 'foo']),
2191 pa.DictionaryArray.from_arrays(
2192 pa.array([0, None, 1, 0], type='int32'),
2193 ['foo', 'bar'])),
2194 (pa.array(['foo', None, 'bar', 'foo'], type=pa.large_binary()),
2195 pa.DictionaryArray.from_arrays(
2196 pa.array([0, None, 1, 0], type='int32'),
2197 pa.array(['foo', 'bar'], type=pa.large_binary()))),
2198 ]
2199 for arr, expected in cases:
2200 result = arr.dictionary_encode()
2201 assert result.equals(expected)
2202 result = pa.chunked_array([arr]).dictionary_encode()
2203 assert result.num_chunks == 1
2204 assert result.chunk(0).equals(expected)
2205 result = pa.chunked_array([], type=arr.type).dictionary_encode()
2206 assert result.num_chunks == 0
2207 assert result.type == expected.type
2208
2209
2210def test_dictionary_encode_sliced():

Callers

nothing calls this directly

Calls 3

equalsMethod · 0.80
chunked_arrayMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected