-
-
Notifications
You must be signed in to change notification settings - Fork 324
/
Copy pathtest_arrow.py
57 lines (48 loc) · 1.36 KB
/
test_arrow.py
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
55
56
57
import numpy as np
import pytest
from zarr.abc.store import Store
from zarr.array import Array
from zarr.codecs import ArrowRecordBatchCodec
from zarr.store.core import StorePath
@pytest.mark.parametrize("store", ("local", "memory"), indirect=["store"])
@pytest.mark.parametrize(
"dtype",
[
"uint8",
"uint16",
"uint32",
"uint64",
"int8",
"int16",
"int32",
"int64",
"float32",
"float64",
],
)
def test_arrow_standard_dtypes(store: Store, dtype) -> None:
data = np.arange(0, 256, dtype=dtype).reshape((16, 16))
a = Array.create(
StorePath(store, path="arrow"),
shape=data.shape,
chunk_shape=(16, 16),
dtype=data.dtype,
fill_value=0,
codecs=[ArrowRecordBatchCodec()],
)
a[:, :] = data
assert np.array_equal(data, a[:, :])
@pytest.mark.parametrize("store", ("local", "memory"), indirect=["store"])
def test_arrow_vlen_string(store: Store) -> None:
strings = ["hello", "world", "this", "is", "a", "test"]
data = np.array(strings).reshape((2, 3))
a = Array.create(
StorePath(store, path="arrow"),
shape=data.shape,
chunk_shape=data.shape,
dtype=data.dtype,
fill_value=0,
codecs=[ArrowRecordBatchCodec()],
)
a[:, :] = data
assert np.array_equal(data, a[:, :])