11import asyncpg
2- import numpy as np
32from pgvector import HalfVector , SparseVector , Vector
43from pgvector .asyncpg import register_vector
54import pytest
@@ -16,7 +15,7 @@ async def test_vector(self):
1615 await register_vector (conn )
1716
1817 embedding = Vector ([1.5 , 2 , 3 ])
19- embedding2 = np . array ( [4.5 , 5 , 6 ])
18+ embedding2 = [4.5 , 5 , 6 ]
2019 await conn .execute ("INSERT INTO asyncpg_items (embedding) VALUES ($1), ($2), (NULL)" , embedding , embedding2 )
2120
2221 res = await conn .fetch ("SELECT * FROM asyncpg_items ORDER BY id" )
@@ -111,7 +110,7 @@ async def test_vector_array(self):
111110 embeddings = [Vector ([1.5 , 2 , 3 ]), Vector ([4.5 , 5 , 6 ])]
112111 await conn .execute ("INSERT INTO asyncpg_items (embeddings) VALUES ($1)" , embeddings )
113112
114- embeddings2 = [np . array ( [1.5 , 2 , 3 ]), np . array ( [4.5 , 5 , 6 ]) ]
113+ embeddings2 = [[1.5 , 2 , 3 ], [4.5 , 5 , 6 ]]
115114 await conn .execute ("INSERT INTO asyncpg_items (embeddings) VALUES (ARRAY[$1, $2]::vector[])" , embeddings2 [0 ], embeddings2 [1 ])
116115
117116 res = await conn .fetch ("SELECT * FROM asyncpg_items ORDER BY id" )
@@ -133,7 +132,7 @@ async def init(conn):
133132 await conn .execute ('CREATE TABLE asyncpg_items (id bigserial PRIMARY KEY, embedding vector(3))' )
134133
135134 embedding = Vector ([1.5 , 2 , 3 ])
136- embedding2 = np . array ( [1.5 , 2 , 3 ])
135+ embedding2 = [1.5 , 2 , 3 ]
137136 await conn .execute ("INSERT INTO asyncpg_items (embedding) VALUES ($1), ($2), (NULL)" , embedding , embedding2 )
138137
139138 res = await conn .fetch ("SELECT * FROM asyncpg_items ORDER BY id" )
0 commit comments