From 57cd9014dc0a92108ca181eb750652f642b484fb Mon Sep 17 00:00:00 2001 From: Gatefixer <313497061+lancedb-gatefixer[bot]@users.noreply.github.com> Date: Wed, 5 Aug 2026 17:50:40 +0000 Subject: [PATCH] test(python): cover float16 table creation from Arrow data --- python/python/tests/test_table.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/python/python/tests/test_table.py b/python/python/tests/test_table.py index 542c944c8..a306a5f84 100644 --- a/python/python/tests/test_table.py +++ b/python/python/tests/test_table.py @@ -2537,22 +2537,22 @@ def test_create_with_embedding_function(mem_db: DBConnection): assert actual == expected -def test_create_f16_table(mem_db: DBConnection): - class MyTable(LanceModel): - text: str - vector: Vector(32, value_type=pa.float16()) - +def test_create_f16_table_from_arrow_data(mem_db: DBConnection): + dimension = 32 + num_rows = 512 + values = pa.array( + np.random.default_rng(42) + .standard_normal(num_rows * dimension) + .astype(np.float16) + ) df = pa.table( { - "text": [f"s-{i}" for i in range(512)], - "vector": [np.random.randn(32).astype(np.float16) for _ in range(512)], + "text": [f"s-{i}" for i in range(num_rows)], + "vector": pa.FixedSizeListArray.from_arrays(values, dimension), } ) - table = mem_db.create_table( - "f16_tbl", - schema=MyTable, - ) - table.add(df) + table = mem_db.create_table("f16_tbl", data=df) + assert table.schema.field("vector").type == pa.list_(pa.float16(), dimension) table.create_index(num_partitions=2, num_sub_vectors=2) query = df["vector"][2].as_py()