Skip to content

Commit 82cf977

Browse files
committed
moved 2 tests to test_engine_object
1 parent 67e8c7a commit 82cf977

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

python/cocoindex/tests/test_engine_object.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import dataclasses
22
import datetime
3-
from typing import TypedDict, NamedTuple
3+
from typing import TypedDict, NamedTuple, Literal
44

55
import numpy as np
66
from numpy.typing import NDArray
77
import pytest
88

9+
from cocoindex.typing import Vector
910
from cocoindex.engine_object import dump_engine_object, load_engine_object
1011

1112
# Optional Pydantic support for testing
@@ -192,6 +193,30 @@ class TestClass:
192193
pass # Expected behavior
193194

194195

196+
def test_dump_vector_type_annotation_with_dim() -> None:
197+
"""Test dumping a vector type annotation with a specified dimension."""
198+
expected_dump = {
199+
"type": {
200+
"kind": "Vector",
201+
"element_type": {"kind": "Float32"},
202+
"dimension": 3,
203+
}
204+
}
205+
assert dump_engine_object(Vector[np.float32, Literal[3]]) == expected_dump
206+
207+
208+
def test_dump_vector_type_annotation_no_dim() -> None:
209+
"""Test dumping a vector type annotation with no dimension."""
210+
expected_dump_no_dim = {
211+
"type": {
212+
"kind": "Vector",
213+
"element_type": {"kind": "Float64"},
214+
"dimension": None,
215+
}
216+
}
217+
assert dump_engine_object(Vector[np.float64]) == expected_dump_no_dim
218+
219+
195220
@pytest.mark.skipif(not PYDANTIC_AVAILABLE, reason="Pydantic not available")
196221
def test_pydantic_unsupported_type_still_fails() -> None:
197222
"""Test that fields with unsupported types still cause errors when missing."""

python/cocoindex/tests/test_engine_value.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,30 +1005,6 @@ def test_decode_error_non_nullable_or_non_list_vector() -> None:
10051005
decoder("not a list")
10061006

10071007

1008-
# def test_dump_vector_type_annotation_with_dim() -> None:
1009-
# """Test dumping a vector type annotation with a specified dimension."""
1010-
# expected_dump = {
1011-
# "type": {
1012-
# "kind": "Vector",
1013-
# "element_type": {"kind": "Float32"},
1014-
# "dimension": 3,
1015-
# }
1016-
# }
1017-
# assert dump_engine_object(Float32VectorType) == expected_dump
1018-
1019-
1020-
# def test_dump_vector_type_annotation_no_dim() -> None:
1021-
# """Test dumping a vector type annotation with no dimension."""
1022-
# expected_dump_no_dim = {
1023-
# "type": {
1024-
# "kind": "Vector",
1025-
# "element_type": {"kind": "Float64"},
1026-
# "dimension": None,
1027-
# }
1028-
# }
1029-
# assert dump_engine_object(Float64VectorTypeNoDim) == expected_dump_no_dim
1030-
1031-
10321008
def test_full_roundtrip_vector_numeric_types() -> None:
10331009
"""Test full roundtrip for numeric vector types using NDArray."""
10341010
value_f32 = np.array([1.0, 2.0, 3.0], dtype=np.float32)

0 commit comments

Comments
 (0)