File: test_2293_unflatten_typetracer.py

package info (click to toggle)
python-awkward 2.6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 23,088 kB
  • sloc: python: 148,689; cpp: 33,562; sh: 432; makefile: 21; javascript: 8
file content (53 lines) | stat: -rw-r--r-- 1,368 bytes parent folder | download
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
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE

from __future__ import annotations

import pytest  # noqa: F401

import awkward as ak


def test_array_with_length():
    array = ak.Array(
        [[100.0, 200.0, 22.0], [4.0, 5.0], [8.0, 9.0, 10.0, 11.0]], backend="typetracer"
    )
    counts = ak.Array([2, 1, 1, 1, 2, 2])
    ak.unflatten(array, counts)


def test_array_without_length():
    array = ak.Array(
        ak.to_layout(
            [[100.0, 200.0, 22.0], [4.0, 5.0], [8.0, 9.0, 10.0, 11.0]]
        ).to_typetracer(forget_length=True)
    )
    counts = ak.Array(
        ak.to_layout([2, 1, 1, 1, 2, 2]).to_typetracer(forget_length=True)
    )
    ak.unflatten(array, counts)


def test_scalar():
    array = ak.Array(
        [[100.0, 200.0, 22.0, 8.0], [4.0, 5.0, 5.0, 8.0], [8.0, 9.0, 10.0, 8.0]],
        backend="typetracer",
    )
    ak.unflatten(array, 2)


def test_unknown_scalar():
    array = ak.Array(
        ak.to_layout([[100, 200, 22], [4, 5, 5], [8, 9, 10]]).to_typetracer(
            forget_length=True
        )
    )
    ak.unflatten(array, array[0, 0])


def test_unknown_length():
    array = ak.Array(
        ak.to_layout(
            [[100.0, 200.0, 22.0], [4.0, 5.0, 5.0], [8.0, 9.0, 10.0]]
        ).to_typetracer(forget_length=True)
    )
    ak.unflatten(array, array.layout.length)