cocoindex 0.1.59__cp311-cp311-manylinux_2_28_aarch64.whl → 0.1.60__cp311-cp311-manylinux_2_28_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cocoindex/__init__.py CHANGED
@@ -17,7 +17,16 @@ from .llm import LlmSpec, LlmApiType
17
17
  from .index import VectorSimilarityMetric, VectorIndexDef, IndexOptions
18
18
  from .setting import DatabaseConnectionSpec, Settings, ServerSettings
19
19
  from .setting import get_app_namespace
20
- from .typing import Float32, Float64, LocalDateTime, OffsetDateTime, Range, Vector, Json
20
+ from .typing import (
21
+ Int64,
22
+ Float32,
23
+ Float64,
24
+ LocalDateTime,
25
+ OffsetDateTime,
26
+ Range,
27
+ Vector,
28
+ Json,
29
+ )
21
30
 
22
31
  __all__ = [
23
32
  # Submodules
@@ -64,6 +73,7 @@ __all__ = [
64
73
  "ServerSettings",
65
74
  "get_app_namespace",
66
75
  # Typing
76
+ "Int64",
67
77
  "Float32",
68
78
  "Float64",
69
79
  "LocalDateTime",
@@ -78,16 +78,15 @@ def build_engine_value_decoder(
78
78
  return make_engine_value_decoder([], engine_type, python_type or engine_type_in_py)
79
79
 
80
80
 
81
- def validate_full_roundtrip(
81
+ def validate_full_roundtrip_to(
82
82
  value: Any,
83
- value_type: Any = None,
84
- *other_decoded_values: tuple[Any, Any],
83
+ value_type: Any,
84
+ *decoded_values: tuple[Any, Any],
85
85
  ) -> None:
86
86
  """
87
- Validate the given value doesn't change after encoding, sending to engine (using output_type), receiving back and decoding (using input_type).
87
+ Validate the given value becomes specific values after encoding, sending to engine (using output_type), receiving back and decoding (using input_type).
88
88
 
89
- `other_decoded_values` is a tuple of (value, type) pairs.
90
- If provided, also validate the value can be decoded to the other types.
89
+ `decoded_values` is a tuple of (value, type) pairs.
91
90
  """
92
91
  from cocoindex import _engine # type: ignore
93
92
 
@@ -102,15 +101,27 @@ def validate_full_roundtrip(
102
101
  value_from_engine = _engine.testutil.seder_roundtrip(
103
102
  encoded_value, encoded_output_type
104
103
  )
105
- decoder = make_engine_value_decoder([], encoded_output_type, value_type)
106
- decoded_value = decoder(value_from_engine)
107
- assert eq(decoded_value, value), f"{decoded_value} != {value}"
108
104
 
109
- if other_decoded_values is not None:
110
- for other_value, other_type in other_decoded_values:
111
- decoder = make_engine_value_decoder([], encoded_output_type, other_type)
112
- other_decoded_value = decoder(value_from_engine)
113
- assert eq(other_decoded_value, other_value)
105
+ for other_value, other_type in decoded_values:
106
+ decoder = make_engine_value_decoder([], encoded_output_type, other_type)
107
+ other_decoded_value = decoder(value_from_engine)
108
+ assert eq(other_decoded_value, other_value)
109
+
110
+
111
+ def validate_full_roundtrip(
112
+ value: Any,
113
+ value_type: Any,
114
+ *other_decoded_values: tuple[Any, Any],
115
+ ) -> None:
116
+ """
117
+ Validate the given value doesn't change after encoding, sending to engine (using output_type), receiving back and decoding (using input_type).
118
+
119
+ `other_decoded_values` is a tuple of (value, type) pairs.
120
+ If provided, also validate the value can be decoded to the other types.
121
+ """
122
+ validate_full_roundtrip_to(
123
+ value, value_type, (value, value_type), *other_decoded_values
124
+ )
114
125
 
115
126
 
116
127
  def test_encode_engine_value_basic_types() -> None:
@@ -218,17 +229,33 @@ def test_encode_engine_value_none() -> None:
218
229
 
219
230
 
220
231
  def test_roundtrip_basic_types() -> None:
221
- validate_full_roundtrip(42, int, (42, None))
222
- validate_full_roundtrip(3.25, float, (3.25, Float64))
223
232
  validate_full_roundtrip(
224
- 3.25, Float64, (3.25, float), (np.float64(3.25), np.float64)
233
+ 42, cocoindex.Int64, (42, int), (np.int64(42), np.int64), (42, None)
225
234
  )
235
+ validate_full_roundtrip(42, int, (42, cocoindex.Int64))
236
+ validate_full_roundtrip(np.int64(42), np.int64, (42, cocoindex.Int64))
237
+
226
238
  validate_full_roundtrip(
227
- 3.25, Float32, (3.25, float), (np.float32(3.25), np.float32)
239
+ 3.25, Float64, (3.25, float), (np.float64(3.25), np.float64), (3.25, None)
228
240
  )
241
+ validate_full_roundtrip(3.25, float, (3.25, Float64))
242
+ validate_full_roundtrip(np.float64(3.25), np.float64, (3.25, Float64))
243
+
244
+ validate_full_roundtrip(
245
+ 3.25,
246
+ Float32,
247
+ (3.25, float),
248
+ (np.float32(3.25), np.float32),
249
+ (np.float64(3.25), np.float64),
250
+ (3.25, Float64),
251
+ (3.25, None),
252
+ )
253
+ validate_full_roundtrip(np.float32(3.25), np.float32, (3.25, Float32))
254
+
229
255
  validate_full_roundtrip("hello", str, ("hello", None))
230
256
  validate_full_roundtrip(True, bool, (True, None))
231
257
  validate_full_roundtrip(False, bool, (False, None))
258
+ validate_full_roundtrip((1, 2), cocoindex.Range, ((1, 2), None))
232
259
  validate_full_roundtrip(
233
260
  datetime.date(2025, 1, 1), datetime.date, (datetime.date(2025, 1, 1), None)
234
261
  )
@@ -238,14 +265,37 @@ def test_roundtrip_basic_types() -> None:
238
265
  cocoindex.LocalDateTime,
239
266
  (datetime.datetime(2025, 1, 2, 3, 4, 5, 123456), datetime.datetime),
240
267
  )
268
+
269
+ tz = datetime.timezone(datetime.timedelta(hours=5))
241
270
  validate_full_roundtrip(
242
- datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, datetime.UTC),
271
+ datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, tz),
272
+ cocoindex.OffsetDateTime,
273
+ (
274
+ datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, tz),
275
+ datetime.datetime,
276
+ ),
277
+ )
278
+ validate_full_roundtrip(
279
+ datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, tz),
280
+ datetime.datetime,
281
+ (datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, tz), cocoindex.OffsetDateTime),
282
+ )
283
+ validate_full_roundtrip_to(
284
+ datetime.datetime(2025, 1, 2, 3, 4, 5, 123456),
243
285
  cocoindex.OffsetDateTime,
244
286
  (
245
287
  datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, datetime.UTC),
246
288
  datetime.datetime,
247
289
  ),
248
290
  )
291
+ validate_full_roundtrip_to(
292
+ datetime.datetime(2025, 1, 2, 3, 4, 5, 123456),
293
+ datetime.datetime,
294
+ (
295
+ datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, datetime.UTC),
296
+ cocoindex.OffsetDateTime,
297
+ ),
298
+ )
249
299
 
250
300
  uuid_value = uuid.uuid4()
251
301
  validate_full_roundtrip(uuid_value, uuid.UUID, (uuid_value, None))
cocoindex/typing.py CHANGED
@@ -40,6 +40,7 @@ class TypeAttr:
40
40
 
41
41
  Annotation = TypeKind | TypeAttr | VectorInfo
42
42
 
43
+ Int64 = Annotated[int, TypeKind("Int64")]
43
44
  Float32 = Annotated[float, TypeKind("Float32")]
44
45
  Float64 = Annotated[float, TypeKind("Float64")]
45
46
  Range = Annotated[tuple[int, int], TypeKind("Range")]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cocoindex
3
- Version: 0.1.59
3
+ Version: 0.1.60
4
4
  Requires-Dist: click>=8.1.8
5
5
  Requires-Dist: rich>=14.0.0
6
6
  Requires-Dist: python-dotenv>=1.1.0
@@ -1,9 +1,9 @@
1
- cocoindex-0.1.59.dist-info/METADATA,sha256=XyuEgs1E6LhwzhvSwCwjcRmzFZkEHaw-GFEgpp5qVn8,10020
2
- cocoindex-0.1.59.dist-info/WHEEL,sha256=sV4rA9gfzC7j5ItBe_WAiMMgsSnxbuMxVbhOxuTV0TE,109
3
- cocoindex-0.1.59.dist-info/entry_points.txt,sha256=_NretjYVzBdNTn7dK-zgwr7YfG2afz1u1uSE-5bZXF8,46
4
- cocoindex-0.1.59.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
- cocoindex/__init__.py,sha256=MFm-QJzrr0ODJCsAAsPUzJXh8KH1WdZod8F60B1iUYw,1877
6
- cocoindex/_engine.cpython-311-aarch64-linux-gnu.so,sha256=DfjaVOU5-yQEqM4mlWNchUD4Sc2BxFrVA-h2aS67I6U,60988600
1
+ cocoindex-0.1.60.dist-info/METADATA,sha256=TLP5AmkWol7oAVwBcHJfzpQNbilcmrczI6MJX_oVBD0,10020
2
+ cocoindex-0.1.60.dist-info/WHEEL,sha256=sV4rA9gfzC7j5ItBe_WAiMMgsSnxbuMxVbhOxuTV0TE,109
3
+ cocoindex-0.1.60.dist-info/entry_points.txt,sha256=_NretjYVzBdNTn7dK-zgwr7YfG2afz1u1uSE-5bZXF8,46
4
+ cocoindex-0.1.60.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
+ cocoindex/__init__.py,sha256=dSSqO5g2EPoPM3Yo7meIpIh8hWPDArsXFG8kXaQrCwk,1934
6
+ cocoindex/_engine.cpython-311-aarch64-linux-gnu.so,sha256=wcbERulSGwUXnkJtCsxZ4UY0A7xAlBiV4jlHC8xo9ZY,60989352
7
7
  cocoindex/auth_registry.py,sha256=1XqO7ibjmBBd8i11XSJTvTgdz8p1ptW-ZpuSgo_5zzk,716
8
8
  cocoindex/cli.py,sha256=8bDL-Qmd9NYtn1DsDfvUMk45xfAqNf9YTyM7H9KRuNU,21345
9
9
  cocoindex/convert.py,sha256=FsKb2Pfbm7e1VQDOs_AsoiW9PbIUuyHQuqUlrENXmUY,11199
@@ -20,9 +20,9 @@ cocoindex/setup.py,sha256=7uIHKN4FOCuoidPXcKyGTrkqpkl9luL49-6UcnMxYzw,3068
20
20
  cocoindex/sources.py,sha256=JCnOhv1w4o28e03i7yvo4ESicWYAhckkBg5bQlxNH4U,1330
21
21
  cocoindex/targets.py,sha256=Nfh_tpFd1goTnS_cxBjIs4j9zl3Z4Z1JomAQ1dl3Sic,2796
22
22
  cocoindex/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- cocoindex/tests/test_convert.py,sha256=fY3p1gRHZpuWUgk5v28UGPYzyaMI4Qakv4I4qHSNGu8,36528
23
+ cocoindex/tests/test_convert.py,sha256=WmgbaQTYPDnjBfMlIrZWBHipPW7SlrvHYsLLqb--KH0,38025
24
24
  cocoindex/tests/test_optional_database.py,sha256=snAmkNa6wtOSaxoZE1HgjvL5v_ylitt3Jt_9df4Cgdc,8506
25
25
  cocoindex/tests/test_typing.py,sha256=t6UCYShcfonTfjBlGRWPiFGMZ8DGFfABXo6idekPoJE,14757
26
- cocoindex/typing.py,sha256=kPMFVKs2i4SCLzW1Tn5NP_Ev9DAc-2qW6eJ68gpLexU,12580
26
+ cocoindex/typing.py,sha256=s_Hk4Npi8pxJUM2h_7Km0VFrojA8wJU9VDtRqVSL6C0,12622
27
27
  cocoindex/utils.py,sha256=hUhX-XV6XGCtJSEIpBOuDv6VvqImwPlgBxztBTw7u0U,598
28
- cocoindex-0.1.59.dist-info/RECORD,,
28
+ cocoindex-0.1.60.dist-info/RECORD,,