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
|
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE
from __future__ import annotations
import numpy as np
import pytest # noqa: F401
import awkward as ak
def test_numpy():
x = ak.from_numpy(
np.arange(4 * 3, dtype=np.int64).reshape(4, 3), regulararray=False
)
y = ak.from_numpy(
np.arange(4 * 2, dtype=np.int64).reshape(4, 2), regulararray=False
)
assert ak.concatenate((x, y)).type == ak.types.ArrayType(
ak.types.ListType(ak.types.NumpyType("int64")), 8
)
def test_regular():
x = ak.from_numpy(np.arange(4 * 3, dtype=np.int64).reshape(4, 3), regulararray=True)
y = ak.from_numpy(np.arange(4 * 2, dtype=np.int64).reshape(4, 2), regulararray=True)
assert ak.concatenate((x, y)).type == ak.types.ArrayType(
ak.types.ListType(ak.types.NumpyType("int64")), 8
)
def test_regular_mergebool_false():
x = ak.from_numpy(np.zeros((4, 3), dtype=np.bool_), regulararray=True)
y = ak.from_numpy(np.ones((4, 2), dtype=np.int64), regulararray=True)
assert ak.concatenate((x, y), mergebool=False).type == ak.types.ArrayType(
ak.types.UnionType(
[
ak.types.RegularType(ak.types.NumpyType("bool"), 3),
ak.types.RegularType(ak.types.NumpyType("int64"), 2),
]
),
8,
)
def test_regular_mergebool_true():
x = ak.from_numpy(np.zeros((4, 3), dtype=np.bool_), regulararray=True)
y = ak.from_numpy(np.ones((4, 2), dtype=np.int64), regulararray=True)
assert ak.concatenate((x, y), mergebool=True).type == ak.types.ArrayType(
ak.types.ListType(ak.types.NumpyType("int64")), 8
)
|