mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2024-11-10 00:34:29 +00:00
fix hdmf forwardrefs, remove numpy types temporarily
This commit is contained in:
parent
776078ae67
commit
1d527d8f71
2 changed files with 10 additions and 9 deletions
|
@ -22,7 +22,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model_config = ConfigDict(extra="allow")
|
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]] = (
|
NON_COLUMN_FIELDS: ClassVar[tuple[str]] = (
|
||||||
"name",
|
"name",
|
||||||
"colnames",
|
"colnames",
|
||||||
|
@ -33,15 +33,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
colnames: List[str] = Field(default_factory=list)
|
colnames: List[str] = Field(default_factory=list)
|
||||||
|
|
||||||
@property
|
@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)}
|
return {k: getattr(self, k) for i, k in enumerate(self.colnames)}
|
||||||
|
|
||||||
@property
|
@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)]
|
return [getattr(self, k) for i, k in enumerate(self.colnames)]
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(self, item: str) -> Union[list, "NDArray", "VectorData"]: ...
|
def __getitem__(self, item: str) -> Union[list, "NDArray", "VectorDataMixin"]: ...
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(self, item: int) -> DataFrame: ...
|
def __getitem__(self, item: int) -> DataFrame: ...
|
||||||
|
@ -54,7 +54,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
DataFrame,
|
DataFrame,
|
||||||
list,
|
list,
|
||||||
"NDArray",
|
"NDArray",
|
||||||
"VectorData",
|
"VectorDataMixin",
|
||||||
]: ...
|
]: ...
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
|
|
|
@ -12,7 +12,7 @@ from linkml_runtime.linkml_model import (
|
||||||
TypeDefinition,
|
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]:
|
def _make_dtypes() -> List[TypeDefinition]:
|
||||||
|
@ -27,12 +27,13 @@ def _make_dtypes() -> List[TypeDefinition]:
|
||||||
if nwbtype.startswith("uint"):
|
if nwbtype.startswith("uint"):
|
||||||
amin = 0
|
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(
|
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)
|
DTypeTypes.append(atype)
|
||||||
return DTypeTypes
|
return DTypeTypes
|
||||||
|
|
Loading…
Reference in a new issue