1010
1111from cocoindex .typing import (
1212 AnalyzedTypeInfo ,
13- Float32 ,
14- Float64 ,
1513 TypeAttr ,
1614 TypeKind ,
1715 Vector ,
@@ -37,7 +35,7 @@ def test_ndarray_float32_no_dim() -> None:
3735 result = analyze_type_info (typ )
3836 assert result .kind == "Vector"
3937 assert result .vector_info == VectorInfo (dim = None )
40- assert result .elem_type == Float32
38+ assert result .elem_type == np . float32
4139 assert result .key_type is None
4240 assert result .struct_type is None
4341 assert result .nullable is False
@@ -51,7 +49,7 @@ def test_vector_float32_no_dim() -> None:
5149 result = analyze_type_info (typ )
5250 assert result .kind == "Vector"
5351 assert result .vector_info == VectorInfo (dim = None )
54- assert result .elem_type == Float32
52+ assert result .elem_type == np . float32
5553 assert result .key_type is None
5654 assert result .struct_type is None
5755 assert result .nullable is False
@@ -65,7 +63,7 @@ def test_ndarray_float64_with_dim() -> None:
6563 result = analyze_type_info (typ )
6664 assert result .kind == "Vector"
6765 assert result .vector_info == VectorInfo (dim = 128 )
68- assert result .elem_type == Float64
66+ assert result .elem_type == np . float64
6967 assert result .key_type is None
7068 assert result .struct_type is None
7169 assert result .nullable is False
@@ -79,7 +77,7 @@ def test_vector_float32_with_dim() -> None:
7977 result = analyze_type_info (typ )
8078 assert result .kind == "Vector"
8179 assert result .vector_info == VectorInfo (dim = 384 )
82- assert result .elem_type == Float32
80+ assert result .elem_type == np . float32
8381 assert result .key_type is None
8482 assert result .struct_type is None
8583 assert result .nullable is False
@@ -93,7 +91,7 @@ def test_ndarray_int64_no_dim() -> None:
9391 result = analyze_type_info (typ )
9492 assert result .kind == "Vector"
9593 assert result .vector_info == VectorInfo (dim = None )
96- assert get_args ( result .elem_type ) == ( int , TypeKind ( "Int64" ))
94+ assert result .elem_type == np . int64
9795 assert result .nullable is False
9896 assert result .np_number_type is not None
9997 assert get_origin (result .np_number_type ) == np .ndarray
@@ -105,7 +103,7 @@ def test_nullable_ndarray() -> None:
105103 result = analyze_type_info (typ )
106104 assert result .kind == "Vector"
107105 assert result .vector_info == VectorInfo (dim = None )
108- assert result .elem_type == Float32
106+ assert result .elem_type == np . float32
109107 assert result .key_type is None
110108 assert result .struct_type is None
111109 assert result .nullable is True
@@ -121,12 +119,12 @@ def test_scalar_numpy_types() -> None:
121119 (np .float64 , "Float64" ),
122120 ]:
123121 type_info = analyze_type_info (np_type )
124- assert type_info . kind == expected_kind , (
125- f"Expected { expected_kind } for { np_type } , got { type_info .kind } "
126- )
127- assert type_info . np_number_type == np_type , (
128- f"Expected { np_type } , got { type_info .np_number_type } "
129- )
122+ assert (
123+ type_info .kind == expected_kind
124+ ), f"Expected { expected_kind } for { np_type } , got { type_info . kind } "
125+ assert (
126+ type_info .np_number_type == np_type
127+ ), f"Expected { np_type } , got { type_info . np_number_type } "
130128 assert type_info .elem_type is None
131129 assert type_info .vector_info is None
132130
@@ -502,9 +500,9 @@ def test_encode_scalar_numpy_types_schema() -> None:
502500 (np .float64 , "Float64" ),
503501 ]:
504502 schema = encode_enriched_type (np_type )
505- assert schema [ "type" ][ "kind" ] == expected_kind , (
506- f"Expected { expected_kind } for { np_type } , got { schema [' type' ][ ' kind' ] } "
507- )
503+ assert (
504+ schema [" type" ][ " kind" ] == expected_kind
505+ ), f"Expected { expected_kind } for { np_type } , got { schema [ 'type' ][ 'kind' ] } "
508506 assert not schema .get ("nullable" , False )
509507
510508
0 commit comments