@@ -29,91 +29,91 @@ def test_vector(self):
2929
3030 def test_vector_binary_format (self ):
3131 embedding = np .array ([1.5 , 2 , 3 ])
32- res = conn .execute ('SELECT %b::vector' , (embedding ,), binary = True ). fetchone ( )[0 ]
32+ res = next ( conn .execute ('SELECT %b::vector' , (embedding ,), binary = True ))[0 ]
3333 assert np .array_equal (res , embedding )
3434
3535 def test_vector_text_format (self ):
3636 embedding = np .array ([1.5 , 2 , 3 ])
37- res = conn .execute ('SELECT %t::vector' , (embedding ,)). fetchone ( )[0 ]
37+ res = next ( conn .execute ('SELECT %t::vector' , (embedding ,)))[0 ]
3838 assert np .array_equal (res , embedding )
3939
4040 def test_vector_binary_format_correct (self ):
4141 embedding = np .array ([1.5 , 2 , 3 ])
42- res = conn .execute ('SELECT %b::vector::text' , (embedding ,)). fetchone ( )[0 ]
42+ res = next ( conn .execute ('SELECT %b::vector::text' , (embedding ,)))[0 ]
4343 assert res == '[1.5,2,3]'
4444
4545 def test_vector_text_format_non_contiguous (self ):
4646 embedding = np .flipud (np .array ([1.5 , 2 , 3 ]))
4747 assert not embedding .data .contiguous
48- res = conn .execute ('SELECT %t::vector' , (embedding ,)). fetchone ( )[0 ]
48+ res = next ( conn .execute ('SELECT %t::vector' , (embedding ,)))[0 ]
4949 assert np .array_equal (res , [3 , 2 , 1.5 ])
5050
5151 def test_vector_binary_format_non_contiguous (self ):
5252 embedding = np .flipud (np .array ([1.5 , 2 , 3 ]))
5353 assert not embedding .data .contiguous
54- res = conn .execute ('SELECT %b::vector' , (embedding ,)). fetchone ( )[0 ]
54+ res = next ( conn .execute ('SELECT %b::vector' , (embedding ,)))[0 ]
5555 assert np .array_equal (res , [3 , 2 , 1.5 ])
5656
5757 def test_vector_class_binary_format (self ):
5858 embedding = Vector ([1.5 , 2 , 3 ])
59- res = conn .execute ('SELECT %b::vector' , (embedding ,), binary = True ). fetchone ( )[0 ]
59+ res = next ( conn .execute ('SELECT %b::vector' , (embedding ,), binary = True ))[0 ]
6060 assert np .array_equal (res , [1.5 , 2 , 3 ])
6161
6262 def test_vector_class_text_format (self ):
6363 embedding = Vector ([1.5 , 2 , 3 ])
64- res = conn .execute ('SELECT %t::vector' , (embedding ,)). fetchone ( )[0 ]
64+ res = next ( conn .execute ('SELECT %t::vector' , (embedding ,)))[0 ]
6565 assert np .array_equal (res , [1.5 , 2 , 3 ])
6666
6767 def test_halfvec (self ):
6868 embedding = HalfVector ([1.5 , 2 , 3 ])
6969 conn .execute ('INSERT INTO psycopg_items (half_embedding) VALUES (%s)' , (embedding ,))
7070
71- res = conn .execute ('SELECT half_embedding FROM psycopg_items ORDER BY id' ). fetchone ( )[0 ]
71+ res = next ( conn .execute ('SELECT half_embedding FROM psycopg_items ORDER BY id' ))[0 ]
7272 assert res == HalfVector ([1.5 , 2 , 3 ])
7373
7474 def test_halfvec_binary_format (self ):
7575 embedding = HalfVector ([1.5 , 2 , 3 ])
76- res = conn .execute ('SELECT %b::halfvec' , (embedding ,), binary = True ). fetchone ( )[0 ]
76+ res = next ( conn .execute ('SELECT %b::halfvec' , (embedding ,), binary = True ))[0 ]
7777 assert res == HalfVector ([1.5 , 2 , 3 ])
7878
7979 def test_halfvec_text_format (self ):
8080 embedding = HalfVector ([1.5 , 2 , 3 ])
81- res = conn .execute ('SELECT %t::halfvec' , (embedding ,)). fetchone ( )[0 ]
81+ res = next ( conn .execute ('SELECT %t::halfvec' , (embedding ,)))[0 ]
8282 assert res == HalfVector ([1.5 , 2 , 3 ])
8383
8484 def test_bit (self ):
8585 embedding = Bit ([True , False , True ])
8686 conn .execute ('INSERT INTO psycopg_items (binary_embedding) VALUES (%s)' , (embedding ,))
8787
88- res = conn .execute ('SELECT binary_embedding FROM psycopg_items ORDER BY id' ). fetchone ( )[0 ]
88+ res = next ( conn .execute ('SELECT binary_embedding FROM psycopg_items ORDER BY id' ))[0 ]
8989 assert res == '101'
9090
9191 def test_bit_binary_format (self ):
9292 embedding = Bit ([False , True , False , True , False , False , False , False , True ])
93- res = conn .execute ('SELECT %b::bit(9)' , (embedding ,), binary = True ). fetchone ( )[0 ]
93+ res = next ( conn .execute ('SELECT %b::bit(9)' , (embedding ,), binary = True ))[0 ]
9494 assert repr (Bit .from_binary (res )) == 'Bit(010100001)'
9595
9696 def test_bit_text_format (self ):
9797 embedding = Bit ([False , True , False , True , False , False , False , False , True ])
98- res = conn .execute ('SELECT %t::bit(9)' , (embedding ,)). fetchone ( )[0 ]
98+ res = next ( conn .execute ('SELECT %t::bit(9)' , (embedding ,)))[0 ]
9999 assert res == '010100001'
100100 assert repr (Bit (res )) == 'Bit(010100001)'
101101
102102 def test_sparsevec (self ):
103103 embedding = SparseVector ([1.5 , 2 , 3 ])
104104 conn .execute ('INSERT INTO psycopg_items (sparse_embedding) VALUES (%s)' , (embedding ,))
105105
106- res = conn .execute ('SELECT sparse_embedding FROM psycopg_items ORDER BY id' ). fetchone ( )[0 ]
106+ res = next ( conn .execute ('SELECT sparse_embedding FROM psycopg_items ORDER BY id' ))[0 ]
107107 assert res == SparseVector ([1.5 , 2 , 3 ])
108108
109109 def test_sparsevec_binary_format (self ):
110110 embedding = SparseVector ([1.5 , 0 , 2 , 0 , 3 , 0 ])
111- res = conn .execute ('SELECT %b::sparsevec' , (embedding ,), binary = True ). fetchone ( )[0 ]
111+ res = next ( conn .execute ('SELECT %b::sparsevec' , (embedding ,), binary = True ))[0 ]
112112 assert res == embedding
113113
114114 def test_sparsevec_text_format (self ):
115115 embedding = SparseVector ([1.5 , 0 , 2 , 0 , 3 , 0 ])
116- res = conn .execute ('SELECT %t::sparsevec' , (embedding ,)). fetchone ( )[0 ]
116+ res = next ( conn .execute ('SELECT %t::sparsevec' , (embedding ,)))[0 ]
117117 assert res == embedding
118118
119119 def test_text_copy_from (self ):
@@ -170,7 +170,7 @@ def test_vector_array(self):
170170 embeddings = [np .array ([1.5 , 2 , 3 ]), np .array ([4.5 , 5 , 6 ])]
171171 conn .execute ('INSERT INTO psycopg_items (embeddings) VALUES (%s)' , (embeddings ,))
172172
173- res = conn .execute ('SELECT embeddings FROM psycopg_items ORDER BY id' ). fetchone ( )
173+ res = next ( conn .execute ('SELECT embeddings FROM psycopg_items ORDER BY id' ))
174174 assert np .array_equal (res [0 ][0 ], embeddings [0 ])
175175 assert np .array_equal (res [0 ][1 ], embeddings [1 ])
176176
0 commit comments