File: test_1930_unflatten_counts_checks.py

package info (click to toggle)
python-awkward 2.8.10-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 25,140 kB
  • sloc: python: 182,845; cpp: 33,828; sh: 432; makefile: 21; javascript: 8
file content (32 lines) | stat: -rw-r--r-- 953 bytes parent folder | download | duplicates (2)
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
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE

from __future__ import annotations

import numpy as np  # noqa: F401
import pytest

import awkward as ak
import awkward._connect.cling
import awkward._lookup


def test():
    array = ak.Array([[0, 1, 2, 3], [8, 9, 10, 11]])

    with pytest.raises(ValueError, match=r"one-dimensional"):
        ak.unflatten(array, [[4, 2, 2]], axis=-1)

    with pytest.raises(ValueError, match=r"negative counts"):
        ak.unflatten(array, -40, axis=-1)

    with pytest.raises(ValueError, match=r"does not fit"):
        ak.unflatten(array, [-40], axis=-1)

    with pytest.raises(ValueError, match=r"must be integers"):
        ak.unflatten(array, [4.0, 2.0, 2.0], axis=-1)

    with pytest.raises(ValueError, match=r"too large"):
        ak.unflatten(array, 100, axis=-1)

    with pytest.raises(ValueError, match=r"does not fit"):
        ak.unflatten(array, [100], axis=-1)