66import uuid
77from typing import Any , Callable , Dict , List , Optional , Sequence , TypedDict , Union
88
9- import numpy as np
109import pytest
1110
1211from integration .conftest import CollectionFactory , CollectionFactoryGet , _sanitize_collection_name
6261DATE3 = datetime .datetime .strptime ("2019-06-10" , "%Y-%m-%d" ).replace (tzinfo = datetime .timezone .utc )
6362
6463
64+ def get_numpy_vector (input_list : list ) -> Any :
65+ try :
66+ import numpy as np
67+ return np .array (input_list )
68+ except ModuleNotFoundError :
69+ return input_list
70+
71+
6572def test_insert_with_typed_dict_generic (
6673 collection_factory : CollectionFactory ,
6774 collection_factory_get : CollectionFactoryGet ,
@@ -300,21 +307,21 @@ class TestInsertManyWithTypedDict(TypedDict):
300307 [
301308 (
302309 [
303- DataObject (properties = {"name" : "some numpy one" }, vector = np . array ([1 , 2 , 3 ])),
310+ DataObject (properties = {"name" : "some numpy one" }, vector = get_numpy_vector ([1 , 2 , 3 ])),
304311 ],
305312 False ,
306313 ),
307314 (
308315 [
309- DataObject (properties = {"name" : "some numpy one" }, vector = np . array ([1 , 2 , 3 ])),
310- DataObject (properties = {"name" : "some numpy two" }, vector = np . array ([11 , 12 , 13 ])),
316+ DataObject (properties = {"name" : "some numpy one" }, vector = get_numpy_vector ([1 , 2 , 3 ])),
317+ DataObject (properties = {"name" : "some numpy two" }, vector = get_numpy_vector ([11 , 12 , 13 ])),
311318 ],
312319 False ,
313320 ),
314321 (
315322 [
316323 DataObject (
317- properties = {"name" : "some numpy 2d" }, vector = np . array ([[1 , 2 , 3 ], [11 , 12 , 13 ]])
324+ properties = {"name" : "some numpy 2d" }, vector = get_numpy_vector ([[1 , 2 , 3 ], [11 , 12 , 13 ]])
318325 ),
319326 ],
320327 True ,
@@ -326,6 +333,8 @@ def test_insert_many_with_numpy(
326333 objects : Sequence [DataObject [WeaviateProperties , Any ]],
327334 should_error : bool ,
328335) -> None :
336+ if isinstance (objects [0 ].vector , list ):
337+ pytest .skip ("numpy not available" )
329338 collection = collection_factory (
330339 properties = [Property (name = "Name" , data_type = DataType .TEXT )],
331340 vectorizer_config = Configure .Vectorizer .none (),
0 commit comments