Skip to content

Commit 80e7570

Browse files
committed
Added more tests for Django
1 parent 13c57d2 commit 80e7570

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/test_django.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,19 @@ def test_vector_l2_distance(self):
181181
assert [v.id for v in items] == [1, 3, 2]
182182
assert [v.distance for v in items] == [0, 1, sqrt(3)]
183183

184+
def test_vector_l2_distance_list(self):
185+
create_items()
186+
distance = L2Distance('embedding', [1, 1, 1])
187+
items = Item.objects.annotate(distance=distance).order_by(distance)
188+
assert [v.id for v in items] == [1, 3, 2]
189+
assert [v.distance for v in items] == [0, 1, sqrt(3)]
190+
191+
def test_vector_l2_distance_none(self):
192+
create_items()
193+
distance = L2Distance('embedding', None)
194+
items = Item.objects.annotate(distance=distance).order_by(distance)
195+
assert [v.distance for v in items] == [None, None, None]
196+
184197
def test_vector_max_inner_product(self):
185198
create_items()
186199
distance = MaxInnerProduct('embedding', [1, 1, 1])

0 commit comments

Comments
 (0)