From 1d527d8f715daff0e4d3c266d14eb7bc6337d31d Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Wed, 31 Jul 2024 01:54:14 -0700 Subject: [PATCH] fix hdmf forwardrefs, remove numpy types temporarily --- nwb_linkml/src/nwb_linkml/includes/hdmf.py | 10 +++++----- nwb_linkml/src/nwb_linkml/lang_elements.py | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/nwb_linkml/src/nwb_linkml/includes/hdmf.py b/nwb_linkml/src/nwb_linkml/includes/hdmf.py index 9027ae6..10aa05f 100644 --- a/nwb_linkml/src/nwb_linkml/includes/hdmf.py +++ b/nwb_linkml/src/nwb_linkml/includes/hdmf.py @@ -22,7 +22,7 @@ class DynamicTableMixin(BaseModel): """ model_config = ConfigDict(extra="allow") - __pydantic_extra__: Dict[str, Union[list, "NDArray", "VectorData"]] + __pydantic_extra__: Dict[str, Union[list, "NDArray", "VectorDataMixin"]] NON_COLUMN_FIELDS: ClassVar[tuple[str]] = ( "name", "colnames", @@ -33,15 +33,15 @@ class DynamicTableMixin(BaseModel): colnames: List[str] = Field(default_factory=list) @property - def _columns(self) -> Dict[str, Union[list, "NDArray", "VectorData"]]: + def _columns(self) -> Dict[str, Union[list, "NDArray", "VectorDataMixin"]]: return {k: getattr(self, k) for i, k in enumerate(self.colnames)} @property - def _columns_list(self) -> List[Union[list, "NDArray", "VectorData"]]: + def _columns_list(self) -> List[Union[list, "NDArray", "VectorDataMixin"]]: return [getattr(self, k) for i, k in enumerate(self.colnames)] @overload - def __getitem__(self, item: str) -> Union[list, "NDArray", "VectorData"]: ... + def __getitem__(self, item: str) -> Union[list, "NDArray", "VectorDataMixin"]: ... @overload def __getitem__(self, item: int) -> DataFrame: ... @@ -54,7 +54,7 @@ class DynamicTableMixin(BaseModel): DataFrame, list, "NDArray", - "VectorData", + "VectorDataMixin", ]: ... @overload diff --git a/nwb_linkml/src/nwb_linkml/lang_elements.py b/nwb_linkml/src/nwb_linkml/lang_elements.py index 7bb68c4..4ebd6d4 100644 --- a/nwb_linkml/src/nwb_linkml/lang_elements.py +++ b/nwb_linkml/src/nwb_linkml/lang_elements.py @@ -12,7 +12,7 @@ from linkml_runtime.linkml_model import ( TypeDefinition, ) -from nwb_linkml.maps import flat_to_linkml, flat_to_np +from nwb_linkml.maps import flat_to_linkml def _make_dtypes() -> List[TypeDefinition]: @@ -27,12 +27,13 @@ def _make_dtypes() -> List[TypeDefinition]: if nwbtype.startswith("uint"): amin = 0 - np_type = flat_to_np[nwbtype] + # FIXME: Restore numpy types when we wrap them :) + # np_type = flat_to_np[nwbtype] - repr_string = f"np.{np_type.__name__}" if np_type.__module__ == "numpy" else None + # repr_string = f"np.{np_type.__name__}" if np_type.__module__ == "numpy" else None atype = TypeDefinition( - name=nwbtype, minimum_value=amin, typeof=linkmltype, repr=repr_string + name=nwbtype, minimum_value=amin, typeof=linkmltype, # repr=repr_string ) DTypeTypes.append(atype) return DTypeTypes