| 845 | |
| 846 | |
| 847 | def test_dictionary(pickle_module): |
| 848 | indices = pa.array([2, None, 1, 2, 0, None]) |
| 849 | dictionary = pa.array(['foo', 'bar', 'baz']) |
| 850 | |
| 851 | arr = pa.DictionaryArray.from_arrays(indices, dictionary) |
| 852 | expected = ['baz', None, 'bar', 'baz', 'foo', None] |
| 853 | assert arr.to_pylist() == expected |
| 854 | |
| 855 | for j, (i, v) in enumerate(zip(indices, expected)): |
| 856 | s = arr[j] |
| 857 | |
| 858 | assert s.as_py() == v |
| 859 | assert s.value.as_py() == v |
| 860 | assert s.index.equals(i) |
| 861 | assert s.dictionary.equals(dictionary) |
| 862 | |
| 863 | restored = pickle_module.loads(pickle_module.dumps(s)) |
| 864 | assert restored.equals(s) |
| 865 | |
| 866 | |
| 867 | def test_run_end_encoded(): |