-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathtest_array.py
More file actions
45 lines (31 loc) · 1.11 KB
/
test_array.py
File metadata and controls
45 lines (31 loc) · 1.11 KB
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
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright the Vortex contributors
import pyarrow as pa
import pytest
import vortex
def test_primitive_array_round_trip():
a = pa.array([0, 1, 2, 3])
arr = vortex.array(a)
assert arr.to_arrow_array() == a
def test_array_with_nulls():
a = pa.array([b"123", None], type=pa.string_view())
arr = vortex.array(a)
assert arr.to_arrow_array() == a
def test_varbin_array_round_trip():
a = pa.array(["a", "b", "c"], type=pa.string_view())
arr = vortex.array(a)
assert arr.to_arrow_array() == a
def test_varbin_array_take():
a = vortex.array(pa.array(["a", "b", "c", "d"], type=pa.string_view()))
assert a.take(vortex.array(pa.array([0, 2]))).to_arrow_array() == pa.array(
["a", "c"],
type=pa.string_view(),
)
def test_empty_array():
a = pa.array([], type=pa.uint8())
primitive = vortex.array(a)
assert primitive.to_arrow_array().type == pa.uint8()
@pytest.mark.xfail(raises=IndexError)
def test_scalar_at_out_of_bounds():
a = vortex.array([10, 42, 999, 1992])
_s = a.scalar_at(10)