@@ -259,16 +259,12 @@ async def test_collection_vector_insertion_options_async(
259
259
260
260
acollection_Ycc = async_empty_collection .with_options (
261
261
api_options = APIOptions (
262
- serdes_options = SerdesOptions (
263
- custom_datatypes_in_reading = True ,
264
- ),
262
+ serdes_options = SerdesOptions (custom_datatypes_in_reading = True ),
265
263
),
266
264
)
267
265
acollection_Ncc = async_empty_collection .with_options (
268
266
api_options = APIOptions (
269
- serdes_options = SerdesOptions (
270
- custom_datatypes_in_reading = False ,
271
- ),
267
+ serdes_options = SerdesOptions (custom_datatypes_in_reading = False ),
272
268
),
273
269
)
274
270
docs_Ycc = [
@@ -723,9 +719,7 @@ async def test_collection_distinct_nonhashable_async(
723
719
724
720
d_items_noncustom = await acol .with_options (
725
721
api_options = APIOptions (
726
- serdes_options = SerdesOptions (
727
- custom_datatypes_in_reading = False ,
728
- )
722
+ serdes_options = SerdesOptions (custom_datatypes_in_reading = False )
729
723
),
730
724
).distinct ("f" )
731
725
assert len (d_items_noncustom ) == 8
@@ -1239,16 +1233,12 @@ async def test_custom_datatypes_in_reading_async(
1239
1233
) -> None :
1240
1234
acol_standard_dtypes = async_empty_collection .with_options (
1241
1235
api_options = APIOptions (
1242
- serdes_options = SerdesOptions (
1243
- custom_datatypes_in_reading = False ,
1244
- ),
1236
+ serdes_options = SerdesOptions (custom_datatypes_in_reading = False ),
1245
1237
),
1246
1238
)
1247
1239
acol_custom_dtypes = async_empty_collection .with_options (
1248
1240
api_options = APIOptions (
1249
- serdes_options = SerdesOptions (
1250
- custom_datatypes_in_reading = True ,
1251
- ),
1241
+ serdes_options = SerdesOptions (custom_datatypes_in_reading = True ),
1252
1242
),
1253
1243
)
1254
1244
the_dtime = datetime (2000 , 1 , 1 , 10 , 11 , 12 , 123000 , tzinfo = timezone .utc )
@@ -2004,3 +1994,127 @@ async def test_collection_datatype_insertability_async(
2004
1994
)
2005
1995
< one_day_ms
2006
1996
)
1997
+
1998
+ @pytest .mark .describe (
1999
+ "test of collection binary-encoding vectors everywhere, async"
2000
+ )
2001
+ async def test_collection_binencvectors_everywhere_async (
2002
+ self ,
2003
+ async_empty_collection : DefaultAsyncCollection ,
2004
+ ) -> None :
2005
+ binenc_options = APIOptions (
2006
+ serdes_options = SerdesOptions (binary_encode_vectors = True ),
2007
+ )
2008
+ binenc_acoll = async_empty_collection .with_options (api_options = binenc_options )
2009
+
2010
+ # Using DataAPIVector (the serializer binary-encodes all of these)
2011
+ await binenc_acoll .insert_one ({"_id" : "0" , "$vector" : DataAPIVector ([1 , 1 ])})
2012
+ await binenc_acoll .insert_many (
2013
+ [{"_id" : "X1" , "$vector" : DataAPIVector ([1 , 1 ])}]
2014
+ )
2015
+ await binenc_acoll .update_one (
2016
+ {"_id" : "0" }, {"$set" : {"$vector" : DataAPIVector ([0 , 1 ])}}, upsert = True
2017
+ )
2018
+ await binenc_acoll .update_one (
2019
+ {"_id" : "X2" },
2020
+ {"$setOnInsert" : {"$vector" : DataAPIVector ([0 , 1 ])}},
2021
+ upsert = True ,
2022
+ )
2023
+ await binenc_acoll .update_one (
2024
+ {},
2025
+ sort = {"$vector" : DataAPIVector ([- 1 , 0 ])},
2026
+ update = {"$set" : {"oc" : "ooo0" }},
2027
+ upsert = True ,
2028
+ )
2029
+ await binenc_acoll .update_many (
2030
+ {"_id" : "0" }, {"$set" : {"$vector" : DataAPIVector ([0 , 1 ])}}, upsert = True
2031
+ )
2032
+ await binenc_acoll .update_many (
2033
+ {"_id" : "X3" },
2034
+ {"$setOnInsert" : {"$vector" : DataAPIVector ([0 , 1 ])}},
2035
+ upsert = True ,
2036
+ )
2037
+ await binenc_acoll .replace_one (
2038
+ {"_id" : "0" }, {"$vector" : DataAPIVector ([1 , 2 ])}, upsert = True
2039
+ )
2040
+ await binenc_acoll .replace_one (
2041
+ {}, {"oc" : "ooo1" }, sort = {"$vector" : DataAPIVector ([4 , 1 ])}, upsert = True
2042
+ )
2043
+ await binenc_acoll .delete_one ({}, sort = {"$vector" : DataAPIVector ([5 , 4 ])})
2044
+ await binenc_acoll .find_one (sort = {"$vector" : DataAPIVector ([5 , 4 ])})
2045
+ await binenc_acoll .find (sort = {"$vector" : DataAPIVector ([5 , 4 ])}).to_list ()
2046
+ await binenc_acoll .find_and_rerank (
2047
+ {},
2048
+ sort = {"$hybrid" : {"$vector" : DataAPIVector ([- 1 , - 2 ]), "$lexical" : "bla" }},
2049
+ rerank_query = "bla" ,
2050
+ rerank_on = "$lexical" ,
2051
+ ).to_list ()
2052
+ await binenc_acoll .find_one_and_replace (
2053
+ {}, {"$vector" : DataAPIVector ([5 , 4 ])}, upsert = True
2054
+ )
2055
+ await binenc_acoll .find_one_and_replace (
2056
+ {}, {"oc" : "ooo2" }, sort = {"$vector" : DataAPIVector ([9 , 1 ])}, upsert = True
2057
+ )
2058
+ await binenc_acoll .find_one_and_delete (
2059
+ {}, sort = {"$vector" : DataAPIVector ([9 , 1 ])}
2060
+ )
2061
+ await binenc_acoll .find_one_and_update (
2062
+ {"_id" : "0" }, {"$set" : {"$vector" : DataAPIVector ([5 , 2 ])}}, upsert = True
2063
+ )
2064
+ await binenc_acoll .find_one_and_update (
2065
+ {"_id" : "X4" },
2066
+ {"$setOnInsert" : {"$vector" : DataAPIVector ([5 , 2 ])}},
2067
+ upsert = True ,
2068
+ )
2069
+ await binenc_acoll .find_one_and_update (
2070
+ {},
2071
+ {"$set" : {"oc" : "ooo3" }},
2072
+ sort = {"$vector" : DataAPIVector ([7 , 1 ])},
2073
+ upsert = True ,
2074
+ )
2075
+
2076
+ # Using a plain list (the serializer binary-encodes all of these anyway)
2077
+ await binenc_acoll .insert_one ({"_id" : "L0" , "$vector" : [1 , 1 ]})
2078
+ await binenc_acoll .insert_many ([{"_id" : "LX1" , "$vector" : [1 , 1 ]}])
2079
+ await binenc_acoll .update_one (
2080
+ {"_id" : "L0" }, {"$set" : {"$vector" : [0 , 1 ]}}, upsert = True
2081
+ )
2082
+ await binenc_acoll .update_one (
2083
+ {"_id" : "LX2" }, {"$setOnInsert" : {"$vector" : [0 , 1 ]}}, upsert = True
2084
+ )
2085
+ await binenc_acoll .update_one (
2086
+ {}, sort = {"$vector" : [- 1 , 0 ]}, update = {"$set" : {"oc" : "qqq0" }}, upsert = True
2087
+ )
2088
+ await binenc_acoll .update_many (
2089
+ {"_id" : "L0" }, {"$set" : {"$vector" : [0 , 1 ]}}, upsert = True
2090
+ )
2091
+ await binenc_acoll .update_many (
2092
+ {"_id" : "LX3" }, {"$setOnInsert" : {"$vector" : [0 , 1 ]}}, upsert = True
2093
+ )
2094
+ await binenc_acoll .replace_one ({"_id" : "L0" }, {"$vector" : [1 , 2 ]}, upsert = True )
2095
+ await binenc_acoll .replace_one (
2096
+ {}, {"oc" : "qqq1" }, sort = {"$vector" : [4 , 1 ]}, upsert = True
2097
+ )
2098
+ await binenc_acoll .delete_one ({}, sort = {"$vector" : [5 , 4 ]})
2099
+ await binenc_acoll .find_one (sort = {"$vector" : [5 , 4 ]})
2100
+ await binenc_acoll .find (sort = {"$vector" : [5 , 4 ]}).to_list ()
2101
+ await binenc_acoll .find_and_rerank (
2102
+ {},
2103
+ sort = {"$hybrid" : {"$vector" : [- 1 , - 2 ], "$lexical" : "bla" }},
2104
+ rerank_query = "bla" ,
2105
+ rerank_on = "$lexical" ,
2106
+ ).to_list ()
2107
+ await binenc_acoll .find_one_and_replace ({}, {"$vector" : [5 , 4 ]}, upsert = True )
2108
+ await binenc_acoll .find_one_and_replace (
2109
+ {}, {"oc" : "qqq2" }, sort = {"$vector" : [9 , 1 ]}, upsert = True
2110
+ )
2111
+ await binenc_acoll .find_one_and_delete ({}, sort = {"$vector" : [9 , 1 ]})
2112
+ await binenc_acoll .find_one_and_update (
2113
+ {"_id" : "L0" }, {"$set" : {"$vector" : [5 , 2 ]}}, upsert = True
2114
+ )
2115
+ await binenc_acoll .find_one_and_update (
2116
+ {"_id" : "LX4" }, {"$setOnInsert" : {"$vector" : [5 , 2 ]}}, upsert = True
2117
+ )
2118
+ await binenc_acoll .find_one_and_update (
2119
+ {}, {"$set" : {"oc" : "qqq3" }}, sort = {"$vector" : [7 , 1 ]}, upsert = True
2120
+ )
0 commit comments