def test_view():
    aslist = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    asarray = awkward1.repartition(awkward1.Array(aslist), 3)
    asview = awkward1_numba_arrayview.ArrayView.fromarray(asarray)

    for start in range(10):
        for stop in range(start, 10):
            asview.start = start
            asview.stop = stop
            assert awkward1.to_list(asview.toarray()) == aslist[start:stop]

    asarray = awkward1.repartition(awkward1.Array(aslist), [3, 2, 0, 1, 4])
    asview = awkward1_numba_arrayview.ArrayView.fromarray(asarray)

    for start in range(10):
        for stop in range(start, 10):
            asview.start = start
            asview.stop = stop
            assert awkward1.to_list(asview.toarray()) == aslist[start:stop]

    aslist = [[1, 2, 3], [], [4, 5], [6], [7, 8, 9, 10]]
    asarray = awkward1.repartition(awkward1.Array(aslist), 3)
    asview = awkward1_numba_arrayview.ArrayView.fromarray(asarray)

    for start in range(5):
        for stop in range(start, 5):
            asview.start = start
            asview.stop = stop
            assert awkward1.to_list(asview.toarray()) == aslist[start:stop]
Пример #2
0
def test_with_name_field():
    array = awkward1.Array([{"x": 0.0, "y": []}, {"x": 1.1, "y": [1]}, {"x": 2.2, "y": [2, 2]}, {"x": 3.3, "y": [3, 3, 3]}])
    array2 = awkward1.repartition(array, 2)
    z = awkward1.Array([100, 200, 300, 400])
    z2 = awkward1.repartition(z, 3)

    one = awkward1.with_name(array, "Wilbur")
    assert isinstance(one.layout, awkward1.layout.Content)
    assert one.layout.parameters["__record__"] == "Wilbur"

    one = awkward1.with_name(array2, "Wilbur")
    assert isinstance(one.layout, awkward1.partition.PartitionedArray)
    assert one.layout.partition(0).parameters["__record__"] == "Wilbur"
    assert one.layout.partition(1).parameters["__record__"] == "Wilbur"

    two = awkward1.with_field(array, z, "z")
    assert isinstance(two.layout, awkward1.layout.Content)
    assert awkward1.to_list(two) == [{"x": 0.0, "y": [], "z": 100}, {"x": 1.1, "y": [1], "z": 200}, {"x": 2.2, "y": [2, 2], "z": 300}, {"x": 3.3, "y": [3, 3, 3], "z": 400}]

    two = awkward1.with_field(array2, z, "z")
    assert isinstance(two.layout, awkward1.partition.PartitionedArray)
    assert awkward1.to_list(two) == [{"x": 0.0, "y": [], "z": 100}, {"x": 1.1, "y": [1], "z": 200}, {"x": 2.2, "y": [2, 2], "z": 300}, {"x": 3.3, "y": [3, 3, 3], "z": 400}]

    two = awkward1.with_field(array2, z2, "z")
    assert isinstance(two.layout, awkward1.partition.PartitionedArray)
    assert awkward1.to_list(two) == [{"x": 0.0, "y": [], "z": 100}, {"x": 1.1, "y": [1], "z": 200}, {"x": 2.2, "y": [2, 2], "z": 300}, {"x": 3.3, "y": [3, 3, 3], "z": 400}]

    two = awkward1.with_field(array2, z2, "z")
    assert isinstance(two.layout, awkward1.partition.PartitionedArray)
    assert awkward1.to_list(two) == [{"x": 0.0, "y": [], "z": 100}, {"x": 1.1, "y": [1], "z": 200}, {"x": 2.2, "y": [2, 2], "z": 300}, {"x": 3.3, "y": [3, 3, 3], "z": 400}]
Пример #3
0
def test_len():
    array = awkward1.repartition(awkward1.Array([1.1, 2.2, 3.3, 4.4, 5.5]), 3)

    @numba.njit
    def f1(x):
        return len(x)

    assert f1(array) == 5

    aslist = [{"x": 0.0, "y": []}, {"x": 1.1, "y": [1]}, {"x": 2.2, "y": [2, 2]},
              {"x": 3.3, "y": [3, 3, 3]}, {"x": 4.4, "y": [4, 4, 4, 4]}, {"x": 5.5, "y": [5, 5, 5]},
              {"x": 6.6, "y": [6, 6]}, {"x": 7.7, "y": [7]}, {"x": 8.8, "y": []}]
    asarray = awkward1.repartition(awkward1.Array(aslist), 2)

    assert f1(asarray) == 9
def test_write_read(tmp_path):
    array1 = awkward1.Array([[1, 2, 3], [], [4, 5], [], [], [6, 7, 8, 9]])
    array2 = awkward1.repartition(array1, 2)
    array3 = awkward1.Array(
        [
            {"x": 1, "y": 1.1},
            {"x": 2, "y": 2.2},
            {"x": 3, "y": 3.3},
            {"x": 4, "y": 4.4},
            {"x": 5, "y": 5.5},
            {"x": 6, "y": 6.6},
            {"x": 7, "y": 7.7},
            {"x": 8, "y": 8.8},
            {"x": 9, "y": 9.9},
        ]
    )
    array4 = awkward1.repartition(array3, 2)

    awkward1.to_parquet(array1, os.path.join(tmp_path, "array1.parquet"))
    awkward1.to_parquet(array2, os.path.join(tmp_path, "array2.parquet"))
    awkward1.to_parquet(array3, os.path.join(tmp_path, "array3.parquet"))
    awkward1.to_parquet(array4, os.path.join(tmp_path, "array4.parquet"))

    assert awkward1.to_list(
        awkward1.from_parquet(os.path.join(tmp_path, "array1.parquet"))
    ) == awkward1.to_list(array1)
    assert awkward1.to_list(
        awkward1.from_parquet(os.path.join(tmp_path, "array2.parquet"))
    ) == awkward1.to_list(array2)
    assert awkward1.to_list(
        awkward1.from_parquet(os.path.join(tmp_path, "array3.parquet"))
    ) == awkward1.to_list(array3)
    assert awkward1.to_list(
        awkward1.from_parquet(os.path.join(tmp_path, "array4.parquet"))
    ) == awkward1.to_list(array4)

    assert awkward1.to_list(
        awkward1.from_parquet(os.path.join(tmp_path, "array1.parquet"), lazy=True)
    ) == awkward1.to_list(array1)
    assert awkward1.to_list(
        awkward1.from_parquet(os.path.join(tmp_path, "array2.parquet"), lazy=True)
    ) == awkward1.to_list(array2)
    assert awkward1.to_list(
        awkward1.from_parquet(os.path.join(tmp_path, "array3.parquet"), lazy=True)
    ) == awkward1.to_list(array3)
    assert awkward1.to_list(
        awkward1.from_parquet(os.path.join(tmp_path, "array4.parquet"), lazy=True)
    ) == awkward1.to_list(array4)
def test_mask2():
    array = awkward1.Array([1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9])
    assert isinstance(array.layout, awkward1.layout.Content)
    mask = awkward1.Array(
        [False, False, True, True, False, True, True, False, True])
    assert isinstance(mask.layout, awkward1.layout.Content)

    one = array.mask[mask]
    assert isinstance(one.layout, awkward1.layout.Content)
    assert awkward1.to_list(one) == [
        None, None, 3.3, 4.4, None, 6.6, 7.7, None, 9.9
    ]

    array = awkward1.repartition(array, 4)
    assert isinstance(array.layout, awkward1.partition.PartitionedArray)

    one = array.mask[mask]
    assert isinstance(one.layout, awkward1.partition.PartitionedArray)
    assert awkward1.to_list(one) == [
        None, None, 3.3, 4.4, None, 6.6, 7.7, None, 9.9
    ]

    mask = awkward1.repartition(mask, 3)
    assert isinstance(mask.layout, awkward1.partition.PartitionedArray)

    one = array.mask[mask]
    assert isinstance(one.layout, awkward1.partition.PartitionedArray)
    assert awkward1.to_list(one) == [
        None, None, 3.3, 4.4, None, 6.6, 7.7, None, 9.9
    ]

    array = awkward1.repartition(array, None)
    assert isinstance(array.layout, awkward1.layout.Content)

    one = array.mask[mask]
    assert isinstance(one.layout, awkward1.partition.PartitionedArray)
    assert awkward1.to_list(one) == [
        None, None, 3.3, 4.4, None, 6.6, 7.7, None, 9.9
    ]

    mask = awkward1.repartition(mask, None)
    assert isinstance(mask.layout, awkward1.layout.Content)

    one = array.mask[mask]
    assert isinstance(one.layout, awkward1.layout.Content)
    assert awkward1.to_list(one) == [
        None, None, 3.3, 4.4, None, 6.6, 7.7, None, 9.9
    ]
Пример #6
0
def test_partitioned():
    array = awkward1.repartition(
        awkward1.Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 3)

    form, container, num_partitions = awkward1.to_arrayset(
        array, partition_first=True)
    assert awkward1.from_arrayset(form,
                                  container,
                                  num_partitions,
                                  partition_first=True).tolist() == [
                                      1, 2, 3, 4, 5, 6, 7, 8, 9, 10
                                  ]

    form, container, num_partitions = awkward1.to_arrayset(
        array, partition_first=False)
    assert awkward1.from_arrayset(form,
                                  container,
                                  num_partitions,
                                  partition_first=False).tolist() == [
                                      1, 2, 3, 4, 5, 6, 7, 8, 9, 10
                                  ]

    one = awkward1.Array([1, 2, 3, 4, 5])
    two = awkward1.Array([6, 7, 8, 9, 10])
    container = {}
    form1, _, _ = awkward1.to_arrayset(one, container, 0)
    form2, _, _ = awkward1.to_arrayset(two, container, 1)
    assert form1 == form2

    assert awkward1.from_arrayset(
        form1, container, 2).tolist() == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    assert pickle.loads(pickle.dumps(
        array, -1)).tolist() == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
def test_getitem_1b():
    asnumpy = numpy.array([0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9])
    array = awkward1.repartition(awkward1.Array(asnumpy), 3)

    assert sys.getrefcount(asnumpy) == 3

    @numba.njit
    def f2(x, i1, i2):
        out = x[i1:i2]
        return out

    assert isinstance(
        f2(array, 0, 10).layout, awkward1.partition.PartitionedArray)
    assert isinstance(
        f2(array, 4, 5).layout, awkward1.partition.PartitionedArray)
    assert isinstance(
        f2(array, 5, 5).layout, awkward1.partition.PartitionedArray)

    for start in range(-10, 10):
        for stop in range(-10, 10):
            assert awkward1.to_list(f2(array, start, stop)) == [
                0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9
            ][start:stop]

    assert sys.getrefcount(asnumpy) == 3

    del array
    assert sys.getrefcount(asnumpy) == 2
def test_boxing1():
    asnumpy = numpy.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
    assert sys.getrefcount(asnumpy) == 2

    aslayout = awkward1.layout.NumpyArray(asnumpy)
    aspart = awkward1.repartition(aslayout, 3, highlevel=False)
    asarray = awkward1.Array(aspart)

    assert (sys.getrefcount(asnumpy), sys.getrefcount(aslayout),
            sys.getrefcount(aspart)) == (3, 2, 3)

    @numba.njit
    def f1(x):
        return 3.14

    for i in range(5):
        f1(asarray)
        assert (sys.getrefcount(asnumpy), sys.getrefcount(aslayout),
                sys.getrefcount(aspart)) == (3, 2, 3)

    del asarray
    del aspart
    del aslayout
    import gc
    gc.collect()
    assert sys.getrefcount(asnumpy) == 2
def test_boxing2():
    asnumpy = numpy.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
    assert sys.getrefcount(asnumpy) == 2

    aslayout = awkward1.layout.NumpyArray(asnumpy)
    aspart = awkward1.repartition(aslayout, 3, highlevel=False)
    asarray = awkward1.Array(aspart)

    assert (sys.getrefcount(asnumpy), sys.getrefcount(aslayout),
            sys.getrefcount(aspart)) == (3, 2, 3)

    @numba.njit
    def f2(x):
        return x

    for i in range(10):
        out = f2(asarray)

        assert isinstance(out.layout, awkward1.partition.PartitionedArray)
        assert awkward1.to_list(out) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        assert (sys.getrefcount(asnumpy), sys.getrefcount(aslayout),
                sys.getrefcount(aspart)) == (3, 2, 3)

    del out
    del asarray
    del aspart
    del aslayout
    import gc
    gc.collect()
    assert sys.getrefcount(asnumpy) == 2
Пример #10
0
def test_iter():
    asnumpy = numpy.array([1, 2, 3, 4, 5, 6, 7, 8, 9])

    assert sys.getrefcount(asnumpy) == 2

    array = awkward1.repartition(awkward1.Array(asnumpy), 3)

    assert sys.getrefcount(asnumpy) == 3

    @numba.njit
    def f1(x):
        out = 0
        for xi in x:
            out += xi
        return out

    for i in range(10):
        assert f1(array) == 45
        assert sys.getrefcount(asnumpy) == 3

    del array
    assert sys.getrefcount(asnumpy) == 2

    aslist = [{"x": 0.0, "y": []}, {"x": 1.1, "y": [1]}, {"x": 2.2, "y": [2, 2]},
              {"x": 3.3, "y": [3, 3, 3]}, {"x": 4.4, "y": [4, 4, 4, 4]}, {"x": 5.5, "y": [5, 5, 5]},
              {"x": 6.6, "y": [6, 6]}, {"x": 7.7, "y": [7]}, {"x": 8.8, "y": []}]
    asarray = awkward1.repartition(awkward1.Array(aslist), 2)

    @numba.njit
    def f2(x):
        i = 0
        for xi in x:
            if i == 6:
                return xi["y"]
            i += 1

    assert awkward1.to_list(f2(asarray)) == [6, 6]

    @numba.njit
    def f3(x):
        i = 0
        for xi in x:
            if i == 6:
                return xi
            i += 1

    assert awkward1.to_list(f3(asarray)) == {"x": 6.6, "y": [6, 6]}
Пример #11
0
def test_getitem_1a():
    array = awkward1.repartition(awkward1.Array([0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9]), 3)

    @numba.njit
    def f1(x, i):
        return x[i]

    assert [f1(array, i) for i in range(10)] == [0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9]
    assert [f1(array, -i) for i in range(1, 11)] == [9.9, 8.8, 7.7, 6.6, 5.5, 4.4, 3.3, 2.2, 1.1, 0.0]
def test_repartition():
    array = awkward1.Array([[], [1.1, 2.2, 3.3], [], [], [4.4, 5.5], [], [6.6],
                            [7.7, 8.8, 9.9], []])
    array2 = awkward1.repartition(array, 2)
    array3 = awkward1.repartition(array, 3)
    array4 = awkward1.repartition(array, [3, 2, 3, 1])
    array5 = awkward1.repartition(array2, None)

    assert isinstance(array.layout, awkward1.layout.Content)
    assert isinstance(array2.layout, awkward1.partition.PartitionedArray)
    assert isinstance(array3.layout, awkward1.partition.PartitionedArray)
    assert isinstance(array4.layout, awkward1.partition.PartitionedArray)
    assert isinstance(array5.layout, awkward1.layout.Content)

    assert awkward1.to_list(array) == [[], [1.1, 2.2, 3.3], [], [], [4.4, 5.5],
                                       [], [6.6], [7.7, 8.8, 9.9], []]
    assert awkward1.to_list(array2) == [[], [1.1, 2.2, 3.3], [], [],
                                        [4.4, 5.5], [], [6.6], [7.7, 8.8, 9.9],
                                        []]
    assert awkward1.to_list(array3) == [[], [1.1, 2.2, 3.3], [], [],
                                        [4.4, 5.5], [], [6.6], [7.7, 8.8, 9.9],
                                        []]
    assert awkward1.to_list(array4) == [[], [1.1, 2.2, 3.3], [], [],
                                        [4.4, 5.5], [], [6.6], [7.7, 8.8, 9.9],
                                        []]
    assert awkward1.to_list(array5) == [[], [1.1, 2.2, 3.3], [], [],
                                        [4.4, 5.5], [], [6.6], [7.7, 8.8, 9.9],
                                        []]

    assert [awkward1.to_list(x)
            for x in array2.layout.partitions] == [[[], [1.1, 2.2, 3.3]],
                                                   [[], []], [[4.4, 5.5], []],
                                                   [[6.6], [7.7, 8.8, 9.9]],
                                                   [[]]]
    assert [awkward1.to_list(x)
            for x in array3.layout.partitions] == [[[], [1.1, 2.2, 3.3], []],
                                                   [[], [4.4, 5.5], []],
                                                   [[6.6], [7.7, 8.8, 9.9],
                                                    []]]
    assert [awkward1.to_list(x)
            for x in array4.layout.partitions] == [[[], [1.1, 2.2, 3.3], []],
                                                   [[], [4.4, 5.5]],
                                                   [[], [6.6], [7.7, 8.8,
                                                                9.9]], [[]]]
def test_atleast_1d():
    array = awkward1.Array([1.1, 2.2, 3.3, 4.4, 5.5])
    array2 = awkward1.repartition(array, 2)

    one = awkward1.atleast_1d(array)
    assert isinstance(one, numpy.ndarray)
    assert awkward1.to_list(one) == [1.1, 2.2, 3.3, 4.4, 5.5]

    one = awkward1.atleast_1d(array2)
    assert isinstance(one, numpy.ndarray)
    assert awkward1.to_list(one) == [1.1, 2.2, 3.3, 4.4, 5.5]
Пример #14
0
def test_lazy_partitioned():
    array = awkward1.repartition(
        awkward1.Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 3)
    form, container, num_partitions = awkward1.to_arrayset(array)
    assert num_partitions == 4

    assert awkward1.from_arrayset(form,
                                  container,
                                  num_partitions,
                                  lazy=True,
                                  lazy_lengths=[3, 3, 3, 1]).tolist() == [
                                      1, 2, 3, 4, 5, 6, 7, 8, 9, 10
                                  ]
Пример #15
0
def test_firsts_singletons():
    array = awkward1.Array([None, 1.1, 2.2, None, 3.3, None, None, 4.4, 5.5, None])

    one = awkward1.singletons(array)
    assert awkward1.to_list(one) == [[], [1.1], [2.2], [], [3.3], [], [], [4.4], [5.5], []]
    two = awkward1.firsts(one)
    assert awkward1.to_list(two) == [None, 1.1, 2.2, None, 3.3, None, None, 4.4, 5.5, None]

    array = awkward1.repartition(array, 3)
    assert isinstance(array.layout, awkward1.partition.PartitionedArray)

    one = awkward1.singletons(array)
    assert isinstance(one.layout, awkward1.partition.PartitionedArray)
    assert awkward1.to_list(one) == [[], [1.1], [2.2], [], [3.3], [], [], [4.4], [5.5], []]
    two = awkward1.firsts(one)
    assert isinstance(two.layout, awkward1.partition.PartitionedArray)
    assert awkward1.to_list(two) == [None, 1.1, 2.2, None, 3.3, None, None, 4.4, 5.5, None]
Пример #16
0
def test_0167_strings():
    array = awkward1.repartition(awkward1.Array(["one", "two", "three", "two", "two", "one", "three"]), 3)

    assert awkward1.to_list(array == "two") == [False, True, False, True, True, False, False]
    assert awkward1.to_list("two" == array) == [False, True, False, True, True, False, False]
    assert awkward1.to_list(array == ["two"]) == [False, True, False, True, True, False, False]
    assert awkward1.to_list(["two"] == array) == [False, True, False, True, True, False, False]
    assert awkward1.to_list(array == awkward1.Array(["two"])) == [False, True, False, True, True, False, False]
    assert awkward1.to_list(awkward1.Array(["two"]) == array) == [False, True, False, True, True, False, False]

    array = awkward1.Array([["one", "two", "three"], [], ["two"], ["two", "one"], ["three"]])
    assert awkward1.to_list(array == "two") == [[False, True, False], [], [True], [True, False], [False]]
    assert awkward1.to_list("two" == array) == [[False, True, False], [], [True], [True, False], [False]]
    assert awkward1.to_list(array == ["two"]) == [[False, True, False], [], [True], [True, False], [False]]
    assert awkward1.to_list(["two"] == array) == [[False, True, False], [], [True], [True, False], [False]]
    assert awkward1.to_list(array == awkward1.Array(["two"])) == [[False, True, False], [], [True], [True, False], [False]]
    assert awkward1.to_list(awkward1.Array(["two"]) == array) == [[False, True, False], [], [True], [True, False], [False]]

    array = awkward1.Array([["one", "two", "three"], [], ["two"], ["two", "one"], ["three"]])
    assert awkward1.to_list(array == ["three", "two", "one", "one", "three"]) == [[False, False, True], [], [False], [False, True], [True]]
    assert awkward1.to_list(["three", "two", "one", "one", "three"] == array) == [[False, False, True], [], [False], [False, True], [True]]
    assert awkward1.to_list(array == awkward1.Array(["three", "two", "one", "one", "three"])) == [[False, False, True], [], [False], [False, True], [True]]
    assert awkward1.to_list(awkward1.Array(["three", "two", "one", "one", "three"]) == array) == [[False, False, True], [], [False], [False, True], [True]]
def test_explode(tmp_path):
    array3 = awkward1.Array(
        [
            [{"x": 1, "y": 1.1}, {"x": 2, "y": 2.2}, {"x": 3, "y": 3.3}],
            [],
            [{"x": 4, "y": 4.4}, {"x": 5, "y": 5.5}],
            [],
            [],
            [
                {"x": 6, "y": 6.6},
                {"x": 7, "y": 7.7},
                {"x": 8, "y": 8.8},
                {"x": 9, "y": 9.9},
            ],
        ]
    )
    array4 = awkward1.repartition(array3, 2)

    awkward1.to_parquet(array3, os.path.join(tmp_path, "array3.parquet"), explode_records=True)
    awkward1.to_parquet(array4, os.path.join(tmp_path, "array4.parquet"), explode_records=True)

    assert awkward1.from_parquet(os.path.join(tmp_path, "array3.parquet")) == [
        {"x": [1, 2, 3], "y": [1.1, 2.2, 3.3]},
        {"x": [], "y": []},
        {"x": [4, 5], "y": [4.4, 5.5]},
        {"x": [], "y": []},
        {"x": [], "y": []},
        {"x": [6, 7, 8, 9], "y": [6.6, 7.7, 8.8, 9.9]},
    ]
    assert awkward1.from_parquet(os.path.join(tmp_path, "array4.parquet")) == [
        {"x": [1, 2, 3], "y": [1.1, 2.2, 3.3]},
        {"x": [], "y": []},
        {"x": [4, 5], "y": [4.4, 5.5]},
        {"x": [], "y": []},
        {"x": [], "y": []},
        {"x": [6, 7, 8, 9], "y": [6.6, 7.7, 8.8, 9.9]},
    ]
def test_getitem_2():
    aslist = [{
        "x": 0.0,
        "y": []
    }, {
        "x": 1.1,
        "y": [1]
    }, {
        "x": 2.2,
        "y": [2, 2]
    }, {
        "x": 3.3,
        "y": [3, 3, 3]
    }, {
        "x": 4.4,
        "y": [4, 4, 4, 4]
    }, {
        "x": 5.5,
        "y": [5, 5, 5]
    }, {
        "x": 6.6,
        "y": [6, 6]
    }, {
        "x": 7.7,
        "y": [7]
    }, {
        "x": 8.8,
        "y": []
    }]
    asarray = awkward1.repartition(awkward1.Array(aslist), 2)

    @numba.njit
    def f3a(x):
        return x["x"]

    assert awkward1.to_list(
        f3a(asarray)) == [0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8]

    @numba.njit
    def f3b(x):
        return x.x

    assert awkward1.to_list(
        f3b(asarray)) == [0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8]

    @numba.njit
    def f4a(x):
        return x["y"]

    assert awkward1.to_list(f4a(asarray)) == [[], [1], [2, 2], [3, 3, 3],
                                              [4, 4, 4, 4], [5, 5, 5], [6, 6],
                                              [7], []]

    @numba.njit
    def f4b(x):
        return x.y

    assert awkward1.to_list(f4b(asarray)) == [[], [1], [2, 2], [3, 3, 3],
                                              [4, 4, 4, 4], [5, 5, 5], [6, 6],
                                              [7], []]

    @numba.njit
    def f5a(x, i):
        return x["x"][i]

    assert [f5a(asarray, i) for i in range(-9, 9)]

    @numba.njit
    def f5b(x, i):
        return x[i]["x"]

    assert [f5b(asarray, i) for i in range(-9, 9)]

    @numba.njit
    def f5c(x, i):
        return x.x[i]

    assert [f5c(asarray, i) for i in range(-9, 9)]

    @numba.njit
    def f5d(x, i):
        return x[i].x

    assert [f5d(asarray, i) for i in range(-9, 9)]

    @numba.njit
    def f6a(x, i):
        return x["y"][i]

    assert awkward1.to_list(f6a(asarray, 6)) == [6, 6]
    assert awkward1.to_list(f6a(asarray, -3)) == [6, 6]

    @numba.njit
    def f6b(x, i):
        return x[i]["y"]

    assert awkward1.to_list(f6b(asarray, 6)) == [6, 6]
    assert awkward1.to_list(f6b(asarray, -3)) == [6, 6]

    @numba.njit
    def f6c(x, i):
        return x.y[i]

    assert awkward1.to_list(f6c(asarray, 6)) == [6, 6]
    assert awkward1.to_list(f6c(asarray, -3)) == [6, 6]

    @numba.njit
    def f6d(x, i):
        return x[i].y

    assert awkward1.to_list(f6d(asarray, 6)) == [6, 6]
    assert awkward1.to_list(f6d(asarray, -3)) == [6, 6]
def test_zip():
    x = awkward1.Array([[1, 2, 3], [], [4, 5], [6], [7, 8, 9, 10]])
    y = awkward1.Array([1.1, 2.2, 3.3, 4.4, 5.5])

    one = awkward1.zip({"x": x, "y": y})
    two = awkward1.zip({"x": x, "y": y}, depth_limit=1)
    xx, yy = awkward1.unzip(two)
    assert isinstance(one.layout, awkward1.layout.Content)
    assert isinstance(two.layout, awkward1.layout.Content)
    assert isinstance(xx.layout, awkward1.layout.Content)
    assert isinstance(yy.layout, awkward1.layout.Content)
    assert awkward1.to_list(one) == [[{
        "x": 1,
        "y": 1.1
    }, {
        "x": 2,
        "y": 1.1
    }, {
        "x": 3,
        "y": 1.1
    }], [], [{
        "x": 4,
        "y": 3.3
    }, {
        "x": 5,
        "y": 3.3
    }], [{
        "x": 6,
        "y": 4.4
    }],
                                     [{
                                         "x": 7,
                                         "y": 5.5
                                     }, {
                                         "x": 8,
                                         "y": 5.5
                                     }, {
                                         "x": 9,
                                         "y": 5.5
                                     }, {
                                         "x": 10,
                                         "y": 5.5
                                     }]]
    assert awkward1.to_list(two) == [{
        "x": [1, 2, 3],
        "y": 1.1
    }, {
        "x": [],
        "y": 2.2
    }, {
        "x": [4, 5],
        "y": 3.3
    }, {
        "x": [6],
        "y": 4.4
    }, {
        "x": [7, 8, 9, 10],
        "y": 5.5
    }]
    if not awkward1._util.py27 and not awkward1._util.py35:
        assert awkward1.to_list(xx) == [[1, 2, 3], [], [4, 5], [6],
                                        [7, 8, 9, 10]]
        assert awkward1.to_list(yy) == [1.1, 2.2, 3.3, 4.4, 5.5]

    x = awkward1.repartition(x, 3)
    assert isinstance(x.layout, awkward1.partition.PartitionedArray)
    assert awkward1.to_list(x) == [[1, 2, 3], [], [4, 5], [6], [7, 8, 9, 10]]

    one = awkward1.zip({"x": x, "y": y})
    two = awkward1.zip({"x": x, "y": y}, depth_limit=1)
    xx, yy = awkward1.unzip(two)
    assert isinstance(one.layout, awkward1.partition.PartitionedArray)
    assert isinstance(two.layout, awkward1.partition.PartitionedArray)
    assert isinstance(xx.layout, awkward1.partition.PartitionedArray)
    assert isinstance(yy.layout, awkward1.partition.PartitionedArray)
    assert awkward1.to_list(one) == [[{
        "x": 1,
        "y": 1.1
    }, {
        "x": 2,
        "y": 1.1
    }, {
        "x": 3,
        "y": 1.1
    }], [], [{
        "x": 4,
        "y": 3.3
    }, {
        "x": 5,
        "y": 3.3
    }], [{
        "x": 6,
        "y": 4.4
    }],
                                     [{
                                         "x": 7,
                                         "y": 5.5
                                     }, {
                                         "x": 8,
                                         "y": 5.5
                                     }, {
                                         "x": 9,
                                         "y": 5.5
                                     }, {
                                         "x": 10,
                                         "y": 5.5
                                     }]]
    assert awkward1.to_list(two) == [{
        "x": [1, 2, 3],
        "y": 1.1
    }, {
        "x": [],
        "y": 2.2
    }, {
        "x": [4, 5],
        "y": 3.3
    }, {
        "x": [6],
        "y": 4.4
    }, {
        "x": [7, 8, 9, 10],
        "y": 5.5
    }]
    if not awkward1._util.py27 and not awkward1._util.py35:
        assert awkward1.to_list(xx) == [[1, 2, 3], [], [4, 5], [6],
                                        [7, 8, 9, 10]]
        assert awkward1.to_list(yy) == [1.1, 2.2, 3.3, 4.4, 5.5]

    y = awkward1.repartition(y, 2)
    assert isinstance(x.layout, awkward1.partition.PartitionedArray)
    assert awkward1.to_list(y) == [1.1, 2.2, 3.3, 4.4, 5.5]

    one = awkward1.zip({"x": x, "y": y})
    two = awkward1.zip({"x": x, "y": y}, depth_limit=1)
    xx, yy = awkward1.unzip(two)
    assert isinstance(one.layout, awkward1.partition.PartitionedArray)
    assert isinstance(two.layout, awkward1.partition.PartitionedArray)
    assert isinstance(xx.layout, awkward1.partition.PartitionedArray)
    assert isinstance(yy.layout, awkward1.partition.PartitionedArray)
    assert awkward1.to_list(one) == [[{
        "x": 1,
        "y": 1.1
    }, {
        "x": 2,
        "y": 1.1
    }, {
        "x": 3,
        "y": 1.1
    }], [], [{
        "x": 4,
        "y": 3.3
    }, {
        "x": 5,
        "y": 3.3
    }], [{
        "x": 6,
        "y": 4.4
    }],
                                     [{
                                         "x": 7,
                                         "y": 5.5
                                     }, {
                                         "x": 8,
                                         "y": 5.5
                                     }, {
                                         "x": 9,
                                         "y": 5.5
                                     }, {
                                         "x": 10,
                                         "y": 5.5
                                     }]]
    assert awkward1.to_list(two) == [{
        "x": [1, 2, 3],
        "y": 1.1
    }, {
        "x": [],
        "y": 2.2
    }, {
        "x": [4, 5],
        "y": 3.3
    }, {
        "x": [6],
        "y": 4.4
    }, {
        "x": [7, 8, 9, 10],
        "y": 5.5
    }]
    if not awkward1._util.py27 and not awkward1._util.py35:
        assert awkward1.to_list(xx) == [[1, 2, 3], [], [4, 5], [6],
                                        [7, 8, 9, 10]]
        assert awkward1.to_list(yy) == [1.1, 2.2, 3.3, 4.4, 5.5]

    x = awkward1.repartition(x, None)
    assert isinstance(x.layout, awkward1.layout.Content)
    assert awkward1.to_list(x) == [[1, 2, 3], [], [4, 5], [6], [7, 8, 9, 10]]

    one = awkward1.zip({"x": x, "y": y})
    two = awkward1.zip({"x": x, "y": y}, depth_limit=1)
    xx, yy = awkward1.unzip(two)
    assert isinstance(one.layout, awkward1.partition.PartitionedArray)
    assert isinstance(two.layout, awkward1.partition.PartitionedArray)
    assert isinstance(xx.layout, awkward1.partition.PartitionedArray)
    assert isinstance(yy.layout, awkward1.partition.PartitionedArray)
    assert awkward1.to_list(one) == [[{
        "x": 1,
        "y": 1.1
    }, {
        "x": 2,
        "y": 1.1
    }, {
        "x": 3,
        "y": 1.1
    }], [], [{
        "x": 4,
        "y": 3.3
    }, {
        "x": 5,
        "y": 3.3
    }], [{
        "x": 6,
        "y": 4.4
    }],
                                     [{
                                         "x": 7,
                                         "y": 5.5
                                     }, {
                                         "x": 8,
                                         "y": 5.5
                                     }, {
                                         "x": 9,
                                         "y": 5.5
                                     }, {
                                         "x": 10,
                                         "y": 5.5
                                     }]]
    assert awkward1.to_list(two) == [{
        "x": [1, 2, 3],
        "y": 1.1
    }, {
        "x": [],
        "y": 2.2
    }, {
        "x": [4, 5],
        "y": 3.3
    }, {
        "x": [6],
        "y": 4.4
    }, {
        "x": [7, 8, 9, 10],
        "y": 5.5
    }]
    if not awkward1._util.py27 and not awkward1._util.py35:
        assert awkward1.to_list(xx) == [[1, 2, 3], [], [4, 5], [6],
                                        [7, 8, 9, 10]]
        assert awkward1.to_list(yy) == [1.1, 2.2, 3.3, 4.4, 5.5]

    y = awkward1.repartition(y, None)
    assert isinstance(y.layout, awkward1.layout.Content)
    assert awkward1.to_list(y) == [1.1, 2.2, 3.3, 4.4, 5.5]

    one = awkward1.zip({"x": x, "y": y})
    two = awkward1.zip({"x": x, "y": y}, depth_limit=1)
    xx, yy = awkward1.unzip(two)
    assert isinstance(one.layout, awkward1.layout.Content)
    assert isinstance(two.layout, awkward1.layout.Content)
    assert isinstance(xx.layout, awkward1.layout.Content)
    assert isinstance(yy.layout, awkward1.layout.Content)
    assert awkward1.to_list(one) == [[{
        "x": 1,
        "y": 1.1
    }, {
        "x": 2,
        "y": 1.1
    }, {
        "x": 3,
        "y": 1.1
    }], [], [{
        "x": 4,
        "y": 3.3
    }, {
        "x": 5,
        "y": 3.3
    }], [{
        "x": 6,
        "y": 4.4
    }],
                                     [{
                                         "x": 7,
                                         "y": 5.5
                                     }, {
                                         "x": 8,
                                         "y": 5.5
                                     }, {
                                         "x": 9,
                                         "y": 5.5
                                     }, {
                                         "x": 10,
                                         "y": 5.5
                                     }]]
    assert awkward1.to_list(two) == [{
        "x": [1, 2, 3],
        "y": 1.1
    }, {
        "x": [],
        "y": 2.2
    }, {
        "x": [4, 5],
        "y": 3.3
    }, {
        "x": [6],
        "y": 4.4
    }, {
        "x": [7, 8, 9, 10],
        "y": 5.5
    }]
    if not awkward1._util.py27 and not awkward1._util.py35:
        assert awkward1.to_list(xx) == [[1, 2, 3], [], [4, 5], [6],
                                        [7, 8, 9, 10]]
        assert awkward1.to_list(yy) == [1.1, 2.2, 3.3, 4.4, 5.5]