1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE
from __future__ import annotations
import awkward as ak
def test_ak_zip_no_broadcast_NumpyArray_dict():
a = ak.Array([1])
b = ak.Array([2])
c = ak.zip_no_broadcast({"a": a, "b": b})
assert ak.to_list(c) == ak.to_list(ak.zip({"a": a, "b": b}))
def test_ak_zip_no_broadcast_ListOffsetArray_dict():
a = ak.Array([[1], []])
b = ak.Array([[2], []])
c = ak.zip_no_broadcast({"a": a, "b": b})
assert ak.to_list(c) == ak.to_list(ak.zip({"a": a, "b": b}))
def test_ak_zip_no_broadcast_NumpyArray_list():
a = ak.Array([1])
b = ak.Array([2])
c = ak.zip_no_broadcast([a, b])
assert ak.to_list(c) == ak.to_list(ak.zip([a, b]))
def test_ak_zip_no_broadcast_ListOffsetArray_list():
a = ak.Array([[1], []])
b = ak.Array([[2], []])
c = ak.zip_no_broadcast([a, b])
assert ak.to_list(c) == ak.to_list(ak.zip([a, b]))
def test_typetracer_NumpyArray_non_touching():
tracer = ak.Array([1], backend="typetracer")
tracer, report = ak.typetracer.typetracer_with_report(
tracer.layout.form_with_key(), highlevel=True
)
_ = ak.zip_no_broadcast({"foo": tracer, "bar": tracer})
assert len(report.shape_touched) == 1
assert len(report.data_touched) == 0
def test_typetracer_ListOffsetArray_non_touching():
tracer = ak.Array([[1], [], [2, 3]], backend="typetracer")
tracer, report = ak.typetracer.typetracer_with_report(
tracer.layout.form_with_key(), highlevel=True
)
_ = ak.zip_no_broadcast({"foo": tracer, "bar": tracer})
assert len(report.shape_touched) == 1
assert len(report.data_touched) == 0
|