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

Function test_run_end_encoded

python/pyarrow/tests/test_scalars.py:867–885  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

865
866
867def test_run_end_encoded():
868 run_ends = [3, 5, 10, 12, 19]
869 values = [1, 2, 1, None, 3]
870 arr = pa.RunEndEncodedArray.from_arrays(run_ends, values)
871
872 scalar = arr[0]
873 assert isinstance(scalar, pa.RunEndEncodedScalar)
874 assert isinstance(scalar.value, pa.Int64Scalar)
875 assert scalar.value == pa.array(values)[0]
876 assert scalar.as_py() == 1
877
878 # null -> .value is still a scalar, as_py returns None
879 scalar = arr[10]
880 assert isinstance(scalar.value, pa.Int64Scalar)
881 assert scalar.as_py() is None
882
883 # constructing a scalar directly doesn't work yet
884 with pytest.raises(NotImplementedError):
885 pa.scalar(1, pa.run_end_encoded(pa.int64(), pa.int64()))
886
887
888def test_union(pickle_module):

Callers

nothing calls this directly

Calls 3

as_pyMethod · 0.80
arrayMethod · 0.45
scalarMethod · 0.45

Tested by

no test coverage detected