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

Function test_binary_slice_compatibility

python/pyarrow/tests/test_compute.py:695–716  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

693
694
695def test_binary_slice_compatibility():
696 data = [b"", b"a", b"a\xff", b"ab\x00", b"abc\xfb", b"ab\xf2de"]
697 arr = pa.array(data)
698 for start, stop, step in itertools.product(range(-6, 6),
699 range(-6, 6),
700 range(-3, 4)):
701 if step == 0:
702 continue
703 expected = pa.array([k.as_py()[start:stop:step]
704 for k in arr])
705 result = pc.binary_slice(
706 arr, start=start, stop=stop, step=step)
707 assert expected.equals(result)
708 # Positional options
709 assert pc.binary_slice(arr, start, stop, step) == result
710 # Fixed size binary input / output
711 for item in data:
712 fsb_scalar = pa.scalar(item, type=pa.binary(len(item)))
713 expected = item[start:stop:step]
714 actual = pc.binary_slice(fsb_scalar, start, stop, step)
715 assert actual.type == pa.binary(len(expected))
716 assert actual.as_py() == expected
717
718
719def test_split_pattern():

Callers

nothing calls this directly

Calls 6

lenFunction · 0.85
productMethod · 0.80
as_pyMethod · 0.80
equalsMethod · 0.80
arrayMethod · 0.45
scalarMethod · 0.45

Tested by

no test coverage detected