@@ -75,13 +75,15 @@ def test_halfvec_binary_format(self):
7575 embedding = HalfVector ([1.5 , 2 , 3 ])
7676 res = conn .execute ('SELECT %b::halfvec' , (embedding ,), binary = True ).fetchone ()[0 ]
7777 assert res == HalfVector ([1.5 , 2 , 3 ])
78+ # TODO move
7879 assert res .to_list () == [1.5 , 2 , 3 ]
7980 assert np .array_equal (res .to_numpy (), np .array ([1.5 , 2 , 3 ]))
8081
8182 def test_halfvec_text_format (self ):
8283 embedding = HalfVector ([1.5 , 2 , 3 ])
8384 res = conn .execute ('SELECT %t::halfvec' , (embedding ,)).fetchone ()[0 ]
8485 assert res == HalfVector ([1.5 , 2 , 3 ])
86+ # TODO move
8587 assert res .to_list () == [1.5 , 2 , 3 ]
8688 assert np .array_equal (res .to_numpy (), np .array ([1.5 , 2 , 3 ]))
8789
@@ -114,6 +116,7 @@ def test_sparsevec_binary_format(self):
114116 embedding = SparseVector ([1.5 , 0 , 2 , 0 , 3 , 0 ])
115117 res = conn .execute ('SELECT %b::sparsevec' , (embedding ,), binary = True ).fetchone ()[0 ]
116118 assert res == embedding
119+ # TODO move
117120 assert res .dimensions () == 6
118121 assert res .indices () == [0 , 2 , 4 ]
119122 assert res .values () == [1.5 , 2 , 3 ]
@@ -124,6 +127,7 @@ def test_sparsevec_text_format(self):
124127 embedding = SparseVector ([1.5 , 0 , 2 , 0 , 3 , 0 ])
125128 res = conn .execute ('SELECT %t::sparsevec' , (embedding ,)).fetchone ()[0 ]
126129 assert res == embedding
130+ # TODO move
127131 assert res .dimensions () == 6
128132 assert res .indices () == [0 , 2 , 4 ]
129133 assert res .values () == [1.5 , 2 , 3 ]
@@ -166,8 +170,8 @@ def test_binary_copy_to(self):
166170 cur = conn .cursor ()
167171 with cur .copy ("COPY psycopg_items (embedding, half_embedding) TO STDOUT WITH (FORMAT BINARY)" ) as copy :
168172 for row in copy .rows ():
169- assert Vector .from_binary (row [0 ]).to_list () == [ 1.5 , 2 , 3 ]
170- assert HalfVector .from_binary (row [1 ]). to_list () == [ 1.5 , 2 , 3 ]
173+ assert np . array_equal ( Vector .from_binary (row [0 ]).to_numpy (), embedding )
174+ assert HalfVector .from_binary (row [1 ]) == half_embedding
171175
172176 def test_binary_copy_to_set_types (self ):
173177 embedding = np .array ([1.5 , 2 , 3 ])
@@ -178,7 +182,7 @@ def test_binary_copy_to_set_types(self):
178182 copy .set_types (['vector' , 'halfvec' ])
179183 for row in copy .rows ():
180184 assert np .array_equal (row [0 ], embedding )
181- assert row [1 ]. to_list () == [ 1.5 , 2 , 3 ]
185+ assert row [1 ] == half_embedding
182186
183187 def test_vector_array (self ):
184188 embeddings = [np .array ([1.5 , 2 , 3 ]), np .array ([4.5 , 5 , 6 ])]
0 commit comments