@@ -513,7 +513,7 @@ class OrderKey:
513513 validate_full_roundtrip (value_nt , t_nt )
514514
515515
516- IntVectorType = cocoindex .Vector [np .int32 , Literal [5 ]]
516+ IntVectorType = cocoindex .Vector [np .int64 , Literal [5 ]]
517517
518518
519519def test_vector_as_vector () -> None :
@@ -611,37 +611,6 @@ def test_roundtrip_ndarray_vector():
611611 assert np .array_equal (decoded_nd_f64 , value_nd_f64 )
612612
613613
614- def test_uint_support ():
615- """Test encoding and decoding of unsigned integer vectors."""
616- value_uint8 = np .array ([1 , 2 , 3 , 4 ], dtype = np .uint8 )
617- encoded = encode_engine_value (value_uint8 )
618- assert np .array_equal (encoded , [1 , 2 , 3 , 4 ])
619- decoder = make_engine_value_decoder (
620- [], {"kind" : "Vector" , "element_type" : {"kind" : "UInt8" }}, NDArray [np .uint8 ]
621- )
622- decoded = decoder (encoded )
623- assert np .array_equal (decoded , value_uint8 )
624- assert decoded .dtype == np .uint8
625- value_uint16 = np .array ([1 , 2 , 3 , 4 ], dtype = np .uint16 )
626- encoded = encode_engine_value (value_uint16 )
627- assert np .array_equal (encoded , [1 , 2 , 3 , 4 ])
628- decoder = make_engine_value_decoder (
629- [], {"kind" : "Vector" , "element_type" : {"kind" : "UInt16" }}, NDArray [np .uint16 ]
630- )
631- decoded = decoder (encoded )
632- assert np .array_equal (decoded , value_uint16 )
633- assert decoded .dtype == np .uint16
634- value_uint32 = np .array ([1 , 2 , 3 ], dtype = np .uint32 )
635- encoded = encode_engine_value (value_uint32 )
636- assert np .array_equal (encoded , [1 , 2 , 3 ])
637- decoder = make_engine_value_decoder (
638- [], {"kind" : "Vector" , "element_type" : {"kind" : "UInt32" }}, NDArray [np .uint32 ]
639- )
640- decoded = decoder (encoded )
641- assert np .array_equal (decoded , value_uint32 )
642- assert decoded .dtype == np .uint32
643-
644-
645614def test_ndarray_dimension_mismatch ():
646615 """Test dimension enforcement for Vector with specified dimension."""
647616 value : Float32VectorType = np .array ([1.0 , 2.0 ], dtype = np .float32 )
@@ -658,7 +627,7 @@ def test_list_vector_backward_compatibility():
658627 assert encoded == [1 , 2 , 3 , 4 , 5 ]
659628 decoded = build_engine_value_decoder (IntVectorType )(encoded )
660629 assert isinstance (decoded , np .ndarray )
661- assert decoded .dtype == np .int32
630+ assert decoded .dtype == np .int64
662631 assert np .array_equal (decoded , np .array ([1 , 2 , 3 , 4 , 5 ], dtype = np .int64 ))
663632 value_list : ListIntType = [1 , 2 , 3 , 4 , 5 ]
664633 encoded = encode_engine_value (value_list )
@@ -773,16 +742,20 @@ def test_full_roundtrip_vector_numeric_types() -> None:
773742 [1.0 , 2.0 , 3.0 ], dtype = np .float64
774743 )
775744 validate_full_roundtrip (value_f64 , Vector [np .float64 , Literal [3 ]])
776- value_i32 : Vector [np .int32 , Literal [3 ]] = np .array ([1 , 2 , 3 ], dtype = np .int32 )
777- validate_full_roundtrip (value_i32 , Vector [np .int32 , Literal [3 ]])
778745 value_i64 : Vector [np .int64 , Literal [3 ]] = np .array ([1 , 2 , 3 ], dtype = np .int64 )
779746 validate_full_roundtrip (value_i64 , Vector [np .int64 , Literal [3 ]])
747+ value_i32 : Vector [np .int32 , Literal [3 ]] = np .array ([1 , 2 , 3 ], dtype = np .int32 )
748+ with pytest .raises (ValueError , match = "type unsupported yet" ):
749+ validate_full_roundtrip (value_i32 , Vector [np .int32 , Literal [3 ]])
780750 value_u8 : Vector [np .uint8 , Literal [3 ]] = np .array ([1 , 2 , 3 ], dtype = np .uint8 )
781- validate_full_roundtrip (value_u8 , Vector [np .uint8 , Literal [3 ]])
751+ with pytest .raises (ValueError , match = "type unsupported yet" ):
752+ validate_full_roundtrip (value_u8 , Vector [np .uint8 , Literal [3 ]])
782753 value_u16 : Vector [np .uint16 , Literal [3 ]] = np .array ([1 , 2 , 3 ], dtype = np .uint16 )
783- validate_full_roundtrip (value_u16 , Vector [np .uint16 , Literal [3 ]])
754+ with pytest .raises (ValueError , match = "type unsupported yet" ):
755+ validate_full_roundtrip (value_u16 , Vector [np .uint16 , Literal [3 ]])
784756 value_u32 : Vector [np .uint32 , Literal [3 ]] = np .array ([1 , 2 , 3 ], dtype = np .uint32 )
785- validate_full_roundtrip (value_u32 , Vector [np .uint32 , Literal [3 ]])
757+ with pytest .raises (ValueError , match = "type unsupported yet" ):
758+ validate_full_roundtrip (value_u32 , Vector [np .uint32 , Literal [3 ]])
786759 value_u64 : Vector [np .uint64 , Literal [3 ]] = np .array ([1 , 2 , 3 ], dtype = np .uint64 )
787760 with pytest .raises (ValueError , match = "type unsupported yet" ):
788761 validate_full_roundtrip (value_u64 , Vector [np .uint64 , Literal [3 ]])
0 commit comments