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

Function test_dictionary

python/pyarrow/tests/test_scalars.py:847–864  ·  view source on GitHub ↗
(pickle_module)

Source from the content-addressed store, hash-verified

845
846
847def 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
867def test_run_end_encoded():

Callers

nothing calls this directly

Calls 5

as_pyMethod · 0.80
equalsMethod · 0.80
loadsMethod · 0.80
dumpsMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected