File: test_3097_UnmaskedArray_missing_nextcarry_outindex.py

package info (click to toggle)
python-awkward 2.8.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,932 kB
  • sloc: python: 178,875; cpp: 33,828; sh: 432; makefile: 21; javascript: 8
file content (52 lines) | stat: -rw-r--r-- 1,394 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
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE

from __future__ import annotations

import numpy as np

import awkward as ak
from awkward.contents import (
    BitMaskedArray,
    ByteMaskedArray,
    ListOffsetArray,
    NumpyArray,
    UnmaskedArray,
)
from awkward.index import Index8, Index64, IndexU8


def test_UnmaskedArray():
    layout = ListOffsetArray(
        Index64(np.array([0, 3, 3, 5])),
        UnmaskedArray(NumpyArray(np.array([1.1, 2.2, 3.3, 4.4, 5.5]))),
    )
    out = ak.drop_none(ak.Array(layout), axis=1)
    assert out.tolist() == [[1.1, 2.2, 3.3], [], [4.4, 5.5]]


def test_ByteMaskedArray():
    layout = ListOffsetArray(
        Index64(np.array([0, 3, 3, 5])),
        ByteMaskedArray(
            Index8(np.array([0, 1, 1, 0, 1])),
            NumpyArray(np.array([1.1, 2.2, 3.3, 4.4, 5.5])),
            True,
        ),
    )
    out = ak.drop_none(ak.Array(layout), axis=1)
    assert out.tolist() == [[2.2, 3.3], [], [5.5]]


def test_BitMaskedArray():
    layout = ListOffsetArray(
        Index64(np.array([0, 3, 3, 5])),
        BitMaskedArray(
            IndexU8(np.array([15])),
            NumpyArray(np.array([1.1, 2.2, 3.3, 4.4, 5.5])),
            True,
            5,
            True,
        ),
    )
    out = ak.drop_none(ak.Array(layout), axis=1)
    assert out.tolist() == [[1.1, 2.2, 3.3], [], [4.4]]