@@ -110,12 +110,19 @@ def test_sparsevec(self):
110110 def test_sparsevec_binary_format (self ):
111111 embedding = SparseVector ([1.5 , 0 , 2 , 0 , 3 , 0 ])
112112 res = conn .execute ('SELECT %b::sparsevec' , (embedding ,), binary = True ).fetchone ()[0 ]
113+ assert res .dimensions () == 6
114+ # TODO convert indices and values to lists in 0.4.0
115+ assert res .indices () == (0 , 2 , 4 )
116+ assert res .values () == (1.5 , 2 , 3 )
113117 assert res .to_list () == [1.5 , 0 , 2 , 0 , 3 , 0 ]
114118 assert np .array_equal (res .to_numpy (), np .array ([1.5 , 0 , 2 , 0 , 3 , 0 ]))
115119
116120 def test_sparsevec_text_format (self ):
117121 embedding = SparseVector ([1.5 , 0 , 2 , 0 , 3 , 0 ])
118122 res = conn .execute ('SELECT %t::sparsevec' , (embedding ,)).fetchone ()[0 ]
123+ assert res .dimensions () == 6
124+ assert res .indices () == [0 , 2 , 4 ]
125+ assert res .values () == [1.5 , 2 , 3 ]
119126 assert res .to_list () == [1.5 , 0 , 2 , 0 , 3 , 0 ]
120127 assert np .array_equal (res .to_numpy (), np .array ([1.5 , 0 , 2 , 0 , 3 , 0 ]))
121128
0 commit comments