Skip to content

Commit

Permalink
Add dtype_numpy with medium-effort validation
Browse files Browse the repository at this point in the history
  • Loading branch information
danielballan authored and evalott100 committed Sep 30, 2024
1 parent 3c9ce76 commit 6e76a35
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions event_model/documents/event_descriptor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Optional, Tuple, Union

from typing_extensions import Annotated, Literal, NotRequired, TypedDict

Expand Down Expand Up @@ -42,7 +42,20 @@ class DataKey(TypedDict):
]
dtype: Annotated[
Dtype,
Field(description="The type of the data in the event."),
Field(description="The type of the data in the event, given as a broad JSON schema type."),
]
dtype_numpy: NotRequired[
Annotated[
Union[
str, # e.g. "<u4",
List[Tuple[str, str]], # e.g. [("a", "<u4"), ("b", "<f8")]
],
Field(
description="The type of the data in the event, given as a numpy dtype string (or, for structured dtypes, array)",
pattern="[|<>][tbiufcmMOSUV][0-9]+",
),
# TODO Enforce the regex pattern.
]
]
external: NotRequired[
Annotated[
Expand Down

0 comments on commit 6e76a35

Please sign in to comment.