mirror of
https://github.com/lancedb/lancedb.git
synced 2026-08-18 12:08:35 +00:00
test(python): expect float32 distance arithmetic
This commit is contained in:
@@ -675,14 +675,8 @@ def test_distance_range(table: lancedb.table.Table):
|
||||
assert res["_distance"].to_pylist() == [min_dist, max_dist]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("expression", "expected_type"),
|
||||
[
|
||||
("1 - _distance", pa.float32()),
|
||||
("1.0 - _distance", pa.float64()),
|
||||
],
|
||||
)
|
||||
def test_select_arithmetic_with_distance(table, expression, expected_type):
|
||||
@pytest.mark.parametrize("expression", ["1 - _distance", "1.0 - _distance"])
|
||||
def test_select_arithmetic_with_distance(table, expression):
|
||||
result = (
|
||||
table.search([10, 10])
|
||||
.select({"similarity": expression})
|
||||
@@ -690,7 +684,7 @@ def test_select_arithmetic_with_distance(table, expression, expected_type):
|
||||
.to_arrow()
|
||||
)
|
||||
|
||||
assert result.schema.field("similarity").type == expected_type
|
||||
assert result.schema.field("similarity").type == pa.float32()
|
||||
assert result["similarity"].to_pylist() == pytest.approx(
|
||||
[1 - distance for distance in result["_distance"].to_pylist()]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user