Skip to content

Commit f6667a8

Browse files
committed
Add dtype_numpy with medium-effort validation
1 parent a2f134c commit f6667a8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

event_model/documents/event_descriptor.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, List, Optional
1+
from typing import Any, Dict, List, Optional, Tuple, Union
22

33
from typing_extensions import Annotated, Literal, NotRequired, TypedDict
44

@@ -21,7 +21,20 @@ class DataKey(TypedDict):
2121
]
2222
dtype: Annotated[
2323
Dtype,
24-
Field(description="The type of the data in the event."),
24+
Field(description="The type of the data in the event, given as a broad JSON schema type."),
25+
]
26+
dtype_numpy: NotRequired[
27+
Annotated[
28+
Union[
29+
str, # e.g. "<u4",
30+
List[Tuple[str, str]], # e.g. [("a", "<u4"), ("b", "<f8")]
31+
],
32+
Field(
33+
description="The type of the data in the event, given as a numpy dtype string (or, for structured dtypes, array)"
34+
pattern="[|<>][tbiufcmMOSUV][0-9]+",
35+
),
36+
# TODO Apply the regex pattern to the structured form as well.
37+
]
2538
]
2639
external: NotRequired[
2740
Annotated[

0 commit comments

Comments
 (0)