-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathconftest.py
More file actions
46 lines (35 loc) · 1.49 KB
/
conftest.py
File metadata and controls
46 lines (35 loc) · 1.49 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
46
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright the Vortex contributors
import hashlib
import math
import os
from typing import cast
import pyarrow as pa
import pytest
import vortex as vx
@pytest.fixture(
scope="session",
params=[{"x"}, {"x", "y"}, {"x", "z"}, {"x", "y", "z"}],
ids=["int", "int_str", "int_float", "int_str_float"],
)
def vxf(
tmpdir_factory: pytest.TempPathFactory,
request: pytest.FixtureRequest,
) -> vx.VortexFile:
fname = tmpdir_factory.mktemp("data") / "foo.vortex"
if not os.path.exists(fname):
length = 100_000
columns: dict[str, list[int] | list[float] | list[str]] = {}
assert "x" in request.param # pyright: ignore[reportAny]
columns["x"] = list(range(length))
if "y" in request.param: # pyright: ignore[reportAny]
columns["y"] = [hashlib.md5(x.to_bytes(length=4), usedforsecurity=False).hexdigest() for x in range(length)]
if "z" in request.param: # pyright: ignore[reportAny]
columns["z"] = [math.sqrt(x) for x in range(length)]
a = vx.array(pa.table(columns)) # pyright: ignore[reportCallIssue, reportUnknownArgumentType, reportArgumentType]
vx.io.write(a, str(fname))
return vx.open(str(fname))
@pytest.fixture(scope="session", params=[10_000, 2_000_000], ids=["small", "large"])
def array_fixture(request: pytest.FixtureRequest) -> vx.Array:
size = cast(int, request.param)
return vx.array(pa.table({"x": list(range(size))}))