import lance import numpy as np import pyarrow as pa import pytest from datasets import load_dataset @pytest.fixture def lance_dataset(tmp_path) -> str: data = pa.table( { "id": pa.array([1, 2, 3, 4]), "value": pa.array([10.0, 20.0, 30.0, 40.0]), "text": pa.array(["a", "b", "c", "d"]), "vector": pa.FixedSizeListArray.from_arrays(pa.array([0.1] * 16, pa.float32()), list_size=4), } ) dataset_path = tmp_path / "test_dataset.lance" lance.write_dataset(data, dataset_path) return str(dataset_path) @pytest.fixture def lance_hf_dataset(tmp_path) -> str: data = pa.table( { "id": pa.array([1, 2, 3, 4]), "value": pa.array([10.0, 20.0, 30.0, 40.0]), "text": pa.array(["a", "b", "c", "d"]), "vector": pa.FixedSizeListArray.from_arrays(pa.array([0.1] * 16, pa.float32()), list_size=4), } ) dataset_dir = tmp_path / "data" / "train.lance" dataset_dir.parent.mkdir(parents=True, exist_ok=True) lance.write_dataset(data, dataset_dir) lance.write_dataset(data[:2], tmp_path / "data" / "test.lance") with open(tmp_path / "README.md", "w") as f: f.write("""--- size_categories: - 1M