()
| 2182 | |
| 2183 | |
| 2184 | def 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 | |
| 2210 | def test_dictionary_encode_sliced(): |
nothing calls this directly
no test coverage detected