From 6c07b87ba0df112d68cdbc1a18f840fa15054266 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Mon, 12 Aug 2024 22:57:32 -0700 Subject: [PATCH] regenerate models --- .../pydantic/core/v2_2_0/core_nwb_base.py | 9 + .../pydantic/core/v2_2_0/core_nwb_behavior.py | 9 + .../pydantic/core/v2_2_0/core_nwb_device.py | 9 + .../pydantic/core/v2_2_0/core_nwb_ecephys.py | 9 + .../pydantic/core/v2_2_0/core_nwb_epoch.py | 9 + .../pydantic/core/v2_2_0/core_nwb_file.py | 9 + .../pydantic/core/v2_2_0/core_nwb_icephys.py | 9 + .../pydantic/core/v2_2_0/core_nwb_image.py | 9 + .../pydantic/core/v2_2_0/core_nwb_misc.py | 9 + .../pydantic/core/v2_2_0/core_nwb_ogen.py | 9 + .../pydantic/core/v2_2_0/core_nwb_ophys.py | 9 + .../core/v2_2_0/core_nwb_retinotopy.py | 9 + .../models/pydantic/core/v2_2_0/namespace.py | 9 + .../pydantic/core/v2_2_1/core_nwb_base.py | 9 + .../pydantic/core/v2_2_1/core_nwb_behavior.py | 9 + .../pydantic/core/v2_2_1/core_nwb_device.py | 9 + .../pydantic/core/v2_2_1/core_nwb_ecephys.py | 9 + .../pydantic/core/v2_2_1/core_nwb_epoch.py | 9 + .../pydantic/core/v2_2_1/core_nwb_file.py | 9 + .../pydantic/core/v2_2_1/core_nwb_icephys.py | 9 + .../pydantic/core/v2_2_1/core_nwb_image.py | 9 + .../pydantic/core/v2_2_1/core_nwb_misc.py | 9 + .../pydantic/core/v2_2_1/core_nwb_ogen.py | 9 + .../pydantic/core/v2_2_1/core_nwb_ophys.py | 9 + .../core/v2_2_1/core_nwb_retinotopy.py | 9 + .../models/pydantic/core/v2_2_1/namespace.py | 9 + .../pydantic/core/v2_2_2/core_nwb_base.py | 9 + .../pydantic/core/v2_2_2/core_nwb_behavior.py | 9 + .../pydantic/core/v2_2_2/core_nwb_device.py | 9 + .../pydantic/core/v2_2_2/core_nwb_ecephys.py | 9 + .../pydantic/core/v2_2_2/core_nwb_epoch.py | 9 + .../pydantic/core/v2_2_2/core_nwb_file.py | 9 + .../pydantic/core/v2_2_2/core_nwb_icephys.py | 9 + .../pydantic/core/v2_2_2/core_nwb_image.py | 9 + .../pydantic/core/v2_2_2/core_nwb_misc.py | 9 + .../pydantic/core/v2_2_2/core_nwb_ogen.py | 9 + .../pydantic/core/v2_2_2/core_nwb_ophys.py | 9 + .../core/v2_2_2/core_nwb_retinotopy.py | 9 + .../models/pydantic/core/v2_2_2/namespace.py | 9 + .../pydantic/core/v2_2_4/core_nwb_base.py | 9 + .../pydantic/core/v2_2_4/core_nwb_behavior.py | 9 + .../pydantic/core/v2_2_4/core_nwb_device.py | 9 + .../pydantic/core/v2_2_4/core_nwb_ecephys.py | 9 + .../pydantic/core/v2_2_4/core_nwb_epoch.py | 9 + .../pydantic/core/v2_2_4/core_nwb_file.py | 9 + .../pydantic/core/v2_2_4/core_nwb_icephys.py | 9 + .../pydantic/core/v2_2_4/core_nwb_image.py | 9 + .../pydantic/core/v2_2_4/core_nwb_misc.py | 9 + .../pydantic/core/v2_2_4/core_nwb_ogen.py | 9 + .../pydantic/core/v2_2_4/core_nwb_ophys.py | 9 + .../core/v2_2_4/core_nwb_retinotopy.py | 9 + .../models/pydantic/core/v2_2_4/namespace.py | 9 + .../pydantic/core/v2_2_5/core_nwb_base.py | 9 + .../pydantic/core/v2_2_5/core_nwb_behavior.py | 9 + .../pydantic/core/v2_2_5/core_nwb_device.py | 9 + .../pydantic/core/v2_2_5/core_nwb_ecephys.py | 9 + .../pydantic/core/v2_2_5/core_nwb_epoch.py | 9 + .../pydantic/core/v2_2_5/core_nwb_file.py | 9 + .../pydantic/core/v2_2_5/core_nwb_icephys.py | 9 + .../pydantic/core/v2_2_5/core_nwb_image.py | 9 + .../pydantic/core/v2_2_5/core_nwb_misc.py | 9 + .../pydantic/core/v2_2_5/core_nwb_ogen.py | 9 + .../pydantic/core/v2_2_5/core_nwb_ophys.py | 9 + .../core/v2_2_5/core_nwb_retinotopy.py | 9 + .../models/pydantic/core/v2_2_5/namespace.py | 9 + .../pydantic/core/v2_3_0/core_nwb_base.py | 9 + .../pydantic/core/v2_3_0/core_nwb_behavior.py | 9 + .../pydantic/core/v2_3_0/core_nwb_device.py | 9 + .../pydantic/core/v2_3_0/core_nwb_ecephys.py | 9 + .../pydantic/core/v2_3_0/core_nwb_epoch.py | 9 + .../pydantic/core/v2_3_0/core_nwb_file.py | 9 + .../pydantic/core/v2_3_0/core_nwb_icephys.py | 9 + .../pydantic/core/v2_3_0/core_nwb_image.py | 9 + .../pydantic/core/v2_3_0/core_nwb_misc.py | 9 + .../pydantic/core/v2_3_0/core_nwb_ogen.py | 9 + .../pydantic/core/v2_3_0/core_nwb_ophys.py | 9 + .../core/v2_3_0/core_nwb_retinotopy.py | 9 + .../models/pydantic/core/v2_3_0/namespace.py | 9 + .../pydantic/core/v2_4_0/core_nwb_base.py | 145 +++++++++++++++- .../pydantic/core/v2_4_0/core_nwb_behavior.py | 9 + .../pydantic/core/v2_4_0/core_nwb_device.py | 9 + .../pydantic/core/v2_4_0/core_nwb_ecephys.py | 9 + .../pydantic/core/v2_4_0/core_nwb_epoch.py | 9 + .../pydantic/core/v2_4_0/core_nwb_file.py | 9 + .../pydantic/core/v2_4_0/core_nwb_icephys.py | 9 + .../pydantic/core/v2_4_0/core_nwb_image.py | 9 + .../pydantic/core/v2_4_0/core_nwb_misc.py | 9 + .../pydantic/core/v2_4_0/core_nwb_ogen.py | 9 + .../pydantic/core/v2_4_0/core_nwb_ophys.py | 9 + .../core/v2_4_0/core_nwb_retinotopy.py | 9 + .../models/pydantic/core/v2_4_0/namespace.py | 9 + .../pydantic/core/v2_5_0/core_nwb_base.py | 157 ++++++++++++++++- .../pydantic/core/v2_5_0/core_nwb_behavior.py | 9 + .../pydantic/core/v2_5_0/core_nwb_device.py | 9 + .../pydantic/core/v2_5_0/core_nwb_ecephys.py | 9 + .../pydantic/core/v2_5_0/core_nwb_epoch.py | 9 + .../pydantic/core/v2_5_0/core_nwb_file.py | 9 + .../pydantic/core/v2_5_0/core_nwb_icephys.py | 9 + .../pydantic/core/v2_5_0/core_nwb_image.py | 9 + .../pydantic/core/v2_5_0/core_nwb_misc.py | 9 + .../pydantic/core/v2_5_0/core_nwb_ogen.py | 9 + .../pydantic/core/v2_5_0/core_nwb_ophys.py | 9 + .../core/v2_5_0/core_nwb_retinotopy.py | 9 + .../models/pydantic/core/v2_5_0/namespace.py | 9 + .../core/v2_6_0_alpha/core_nwb_base.py | 157 ++++++++++++++++- .../core/v2_6_0_alpha/core_nwb_behavior.py | 9 + .../core/v2_6_0_alpha/core_nwb_device.py | 9 + .../core/v2_6_0_alpha/core_nwb_ecephys.py | 9 + .../core/v2_6_0_alpha/core_nwb_epoch.py | 9 + .../core/v2_6_0_alpha/core_nwb_file.py | 9 + .../core/v2_6_0_alpha/core_nwb_icephys.py | 9 + .../core/v2_6_0_alpha/core_nwb_image.py | 9 + .../core/v2_6_0_alpha/core_nwb_misc.py | 9 + .../core/v2_6_0_alpha/core_nwb_ogen.py | 9 + .../core/v2_6_0_alpha/core_nwb_ophys.py | 9 + .../core/v2_6_0_alpha/core_nwb_retinotopy.py | 9 + .../pydantic/core/v2_6_0_alpha/namespace.py | 9 + .../pydantic/core/v2_7_0/core_nwb_base.py | 163 +++++++++++++++++- .../pydantic/core/v2_7_0/core_nwb_behavior.py | 9 + .../pydantic/core/v2_7_0/core_nwb_device.py | 9 + .../pydantic/core/v2_7_0/core_nwb_ecephys.py | 9 + .../pydantic/core/v2_7_0/core_nwb_epoch.py | 9 + .../pydantic/core/v2_7_0/core_nwb_file.py | 9 + .../pydantic/core/v2_7_0/core_nwb_icephys.py | 9 + .../pydantic/core/v2_7_0/core_nwb_image.py | 9 + .../pydantic/core/v2_7_0/core_nwb_misc.py | 9 + .../pydantic/core/v2_7_0/core_nwb_ogen.py | 9 + .../pydantic/core/v2_7_0/core_nwb_ophys.py | 9 + .../core/v2_7_0/core_nwb_retinotopy.py | 9 + .../models/pydantic/core/v2_7_0/namespace.py | 9 + .../hdmf_common/v1_1_0/hdmf_common_sparse.py | 9 + .../hdmf_common/v1_1_0/hdmf_common_table.py | 9 + .../pydantic/hdmf_common/v1_1_0/namespace.py | 9 + .../hdmf_common/v1_1_2/hdmf_common_sparse.py | 9 + .../hdmf_common/v1_1_2/hdmf_common_table.py | 9 + .../pydantic/hdmf_common/v1_1_2/namespace.py | 9 + .../hdmf_common/v1_1_3/hdmf_common_sparse.py | 9 + .../hdmf_common/v1_1_3/hdmf_common_table.py | 9 + .../pydantic/hdmf_common/v1_1_3/namespace.py | 9 + .../hdmf_common/v1_2_0/hdmf_common_base.py | 9 + .../hdmf_common/v1_2_0/hdmf_common_sparse.py | 9 + .../hdmf_common/v1_2_0/hdmf_common_table.py | 9 + .../pydantic/hdmf_common/v1_2_0/namespace.py | 9 + .../hdmf_common/v1_2_1/hdmf_common_base.py | 9 + .../hdmf_common/v1_2_1/hdmf_common_sparse.py | 9 + .../hdmf_common/v1_2_1/hdmf_common_table.py | 9 + .../pydantic/hdmf_common/v1_2_1/namespace.py | 9 + .../hdmf_common/v1_3_0/hdmf_common_base.py | 9 + .../v1_3_0/hdmf_common_resources.py | 9 + .../hdmf_common/v1_3_0/hdmf_common_sparse.py | 9 + .../hdmf_common/v1_3_0/hdmf_common_table.py | 9 + .../pydantic/hdmf_common/v1_3_0/namespace.py | 9 + .../hdmf_common/v1_4_0/hdmf_common_base.py | 9 + .../hdmf_common/v1_4_0/hdmf_common_sparse.py | 9 + .../hdmf_common/v1_4_0/hdmf_common_table.py | 9 + .../pydantic/hdmf_common/v1_4_0/namespace.py | 9 + .../hdmf_common/v1_5_0/hdmf_common_base.py | 9 + .../hdmf_common/v1_5_0/hdmf_common_sparse.py | 9 + .../hdmf_common/v1_5_0/hdmf_common_table.py | 9 + .../pydantic/hdmf_common/v1_5_0/namespace.py | 9 + .../hdmf_common/v1_5_1/hdmf_common_base.py | 9 + .../hdmf_common/v1_5_1/hdmf_common_sparse.py | 9 + .../hdmf_common/v1_5_1/hdmf_common_table.py | 9 + .../pydantic/hdmf_common/v1_5_1/namespace.py | 9 + .../hdmf_common/v1_6_0/hdmf_common_base.py | 9 + .../hdmf_common/v1_6_0/hdmf_common_sparse.py | 9 + .../hdmf_common/v1_6_0/hdmf_common_table.py | 9 + .../pydantic/hdmf_common/v1_6_0/namespace.py | 9 + .../hdmf_common/v1_7_0/hdmf_common_base.py | 9 + .../hdmf_common/v1_7_0/hdmf_common_sparse.py | 9 + .../hdmf_common/v1_7_0/hdmf_common_table.py | 9 + .../pydantic/hdmf_common/v1_7_0/namespace.py | 9 + .../hdmf_common/v1_8_0/hdmf_common_base.py | 9 + .../hdmf_common/v1_8_0/hdmf_common_sparse.py | 9 + .../hdmf_common/v1_8_0/hdmf_common_table.py | 44 ++++- .../pydantic/hdmf_common/v1_8_0/namespace.py | 9 + .../v0_1_0/hdmf_experimental_experimental.py | 9 + .../v0_1_0/hdmf_experimental_resources.py | 9 + .../hdmf_experimental/v0_1_0/namespace.py | 9 + .../v0_2_0/hdmf_experimental_experimental.py | 9 + .../v0_2_0/hdmf_experimental_resources.py | 9 + .../hdmf_experimental/v0_2_0/namespace.py | 9 + .../v0_3_0/hdmf_experimental_experimental.py | 9 + .../v0_3_0/hdmf_experimental_resources.py | 9 + .../hdmf_experimental/v0_3_0/namespace.py | 9 + .../v0_4_0/hdmf_experimental_experimental.py | 9 + .../v0_4_0/hdmf_experimental_resources.py | 9 + .../hdmf_experimental/v0_4_0/namespace.py | 9 + .../v0_5_0/hdmf_experimental_experimental.py | 9 + .../v0_5_0/hdmf_experimental_resources.py | 9 + .../hdmf_experimental/v0_5_0/namespace.py | 9 + 191 files changed, 2318 insertions(+), 22 deletions(-) diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_base.py index 99b5906..6cb19f8 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_base.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_behavior.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_behavior.py index addd1ff..095dec1 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_behavior.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_behavior.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_device.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_device.py index 1d43d1b..0456ec3 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_device.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_device.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_ecephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_ecephys.py index d1a96d1..c946ad9 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_ecephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_ecephys.py @@ -44,6 +44,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_epoch.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_epoch.py index 8d0fb5d..33abf7e 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_epoch.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_epoch.py @@ -37,6 +37,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_file.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_file.py index f0e65b0..3bd6ec5 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_file.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_file.py @@ -41,6 +41,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_icephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_icephys.py index 938bf63..f09b466 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_icephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_icephys.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_image.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_image.py index 77e40f9..28ff7b4 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_image.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_image.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_misc.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_misc.py index 6c16a46..b1e0fe6 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_misc.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_misc.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_ogen.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_ogen.py index 4a46e2c..2bbed5f 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_ogen.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_ogen.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_ophys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_ophys.py index 433c454..5321376 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_ophys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_ophys.py @@ -45,6 +45,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_retinotopy.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_retinotopy.py index f63232e..3ee80c2 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_retinotopy.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/core_nwb_retinotopy.py @@ -37,6 +37,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/namespace.py index 0456ea1..e8892b9 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_0/namespace.py @@ -155,6 +155,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_base.py index c8c1162..45c2131 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_base.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_behavior.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_behavior.py index 45af85e..04c20b4 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_behavior.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_behavior.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_device.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_device.py index 83d2f3c..bc309fc 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_device.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_device.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_ecephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_ecephys.py index 92ea135..0a13c81 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_ecephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_ecephys.py @@ -44,6 +44,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_epoch.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_epoch.py index 02fc4d9..3e84ef3 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_epoch.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_epoch.py @@ -37,6 +37,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_file.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_file.py index a17f8e1..199bbda 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_file.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_file.py @@ -41,6 +41,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_icephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_icephys.py index 46321df..9c49daa 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_icephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_icephys.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_image.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_image.py index 97e4aa8..3322ff3 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_image.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_image.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_misc.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_misc.py index 60a591f..c547aef 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_misc.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_misc.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_ogen.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_ogen.py index e94dead..07d8693 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_ogen.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_ogen.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_ophys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_ophys.py index 552d38b..587b5ee 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_ophys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_ophys.py @@ -45,6 +45,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_retinotopy.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_retinotopy.py index 7969ed1..eef6b41 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_retinotopy.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/core_nwb_retinotopy.py @@ -37,6 +37,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/namespace.py index c5d3cba..b5d693b 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_1/namespace.py @@ -155,6 +155,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_base.py index 8dbf06a..4b73640 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_base.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_behavior.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_behavior.py index 9984cf5..aa5631c 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_behavior.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_behavior.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_device.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_device.py index 8f59409..dd0ab6e 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_device.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_device.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_ecephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_ecephys.py index d757e1a..402ccda 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_ecephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_ecephys.py @@ -44,6 +44,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_epoch.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_epoch.py index 083c41f..35bfa64 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_epoch.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_epoch.py @@ -37,6 +37,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_file.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_file.py index ef18f50..c05c351 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_file.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_file.py @@ -41,6 +41,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_icephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_icephys.py index 2b126cd..5cc88ed 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_icephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_icephys.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_image.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_image.py index 2bafac7..88c0781 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_image.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_image.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_misc.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_misc.py index d9914b5..1f41641 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_misc.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_misc.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_ogen.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_ogen.py index cfd0933..e7823a4 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_ogen.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_ogen.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_ophys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_ophys.py index f4f9f20..88bb254 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_ophys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_ophys.py @@ -45,6 +45,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_retinotopy.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_retinotopy.py index 976d7f2..e623a0b 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_retinotopy.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/core_nwb_retinotopy.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/namespace.py index 7b96622..e9737e4 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_2/namespace.py @@ -158,6 +158,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_base.py index 4e8eeca..1d0f436 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_base.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_behavior.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_behavior.py index 9609061..e095079 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_behavior.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_behavior.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_device.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_device.py index fc0ff49..ed9623b 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_device.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_device.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_ecephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_ecephys.py index 7bfffac..e5b05d6 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_ecephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_ecephys.py @@ -44,6 +44,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_epoch.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_epoch.py index 6138ade..8012a74 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_epoch.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_epoch.py @@ -37,6 +37,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_file.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_file.py index 4e54cb8..24f0613 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_file.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_file.py @@ -42,6 +42,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_icephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_icephys.py index d24c902..4272b2e 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_icephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_icephys.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_image.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_image.py index 6d493d6..40370ff 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_image.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_image.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_misc.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_misc.py index 6d705b1..dc6d0a6 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_misc.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_misc.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_ogen.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_ogen.py index 9616063..33f8506 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_ogen.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_ogen.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_ophys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_ophys.py index 9c96489..d7adad4 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_ophys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_ophys.py @@ -50,6 +50,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_retinotopy.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_retinotopy.py index f7b47de..af820b1 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_retinotopy.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/core_nwb_retinotopy.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/namespace.py index 2017869..d4744f0 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_4/namespace.py @@ -165,6 +165,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_base.py index 99ff2d4..8c121de 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_base.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_behavior.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_behavior.py index da7c068..6b298ff 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_behavior.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_behavior.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_device.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_device.py index afc24d2..2b32c15 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_device.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_device.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_ecephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_ecephys.py index 4bd8b19..5869306 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_ecephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_ecephys.py @@ -44,6 +44,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_epoch.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_epoch.py index e66cf1a..4a4f076 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_epoch.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_epoch.py @@ -37,6 +37,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_file.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_file.py index 1aab54d..21932b7 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_file.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_file.py @@ -42,6 +42,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_icephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_icephys.py index 94cf0cf..2dd0607 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_icephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_icephys.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_image.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_image.py index 98d7ef4..483dfd5 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_image.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_image.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_misc.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_misc.py index 4fe4673..b9ef472 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_misc.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_misc.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_ogen.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_ogen.py index c419baf..ead9c1a 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_ogen.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_ogen.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_ophys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_ophys.py index 9b0d75e..1b006ba 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_ophys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_ophys.py @@ -50,6 +50,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_retinotopy.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_retinotopy.py index 3b83056..916660c 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_retinotopy.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/core_nwb_retinotopy.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/namespace.py index 56b42a0..ce33adb 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_2_5/namespace.py @@ -165,6 +165,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_base.py index 8ce2390..4fd6a4a 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_base.py @@ -29,6 +29,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_behavior.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_behavior.py index 9c8a529..898519c 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_behavior.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_behavior.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_device.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_device.py index 0640dac..ec6a770 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_device.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_device.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_ecephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_ecephys.py index 29faa7b..72ca241 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_ecephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_ecephys.py @@ -44,6 +44,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_epoch.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_epoch.py index b6d6397..ff49854 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_epoch.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_epoch.py @@ -37,6 +37,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_file.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_file.py index 987b15e..dcd3d20 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_file.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_file.py @@ -42,6 +42,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_icephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_icephys.py index a439eb5..bac67ab 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_icephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_icephys.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_image.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_image.py index 8425dcc..81ce140 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_image.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_image.py @@ -29,6 +29,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_misc.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_misc.py index 14df410..6e382f4 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_misc.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_misc.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_ogen.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_ogen.py index 56f099a..e77547e 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_ogen.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_ogen.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_ophys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_ophys.py index d6c991a..637d869 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_ophys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_ophys.py @@ -50,6 +50,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_retinotopy.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_retinotopy.py index 26e6c7d..85857c3 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_retinotopy.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/core_nwb_retinotopy.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/namespace.py index fe306d5..6bb4f8d 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_3_0/namespace.py @@ -168,6 +168,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_base.py index aa29c83..2b85c2f 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_base.py @@ -4,9 +4,9 @@ from decimal import Decimal from enum import Enum import re import sys -from typing import Any, ClassVar, List, Literal, Dict, Optional, Union -from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator import numpy as np +from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, overload, Iterable, Tuple +from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container from numpydantic import NDArray, Shape from ...hdmf_common.v1_5_0.hdmf_common_table import VectorData, DynamicTable @@ -29,6 +29,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} @@ -48,6 +57,136 @@ class LinkMLMeta(RootModel): NUMPYDANTIC_VERSION = "1.2.1" + + +class VectorDataMixin(BaseModel): + """ + Mixin class to give VectorData indexing abilities + """ + + _index: Optional["VectorIndex"] = None + + # redefined in `VectorData`, but included here for testing and type checking + value: Optional[NDArray] = None + + def __init__(self, value: Optional[NDArray] = None, **kwargs): + if value is not None and "value" not in kwargs: + kwargs["value"] = value + super().__init__(**kwargs) + + def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any: + if self._index: + # Following hdmf, VectorIndex is the thing that knows how to do the slicing + return self._index[item] + else: + return self.value[item] + + def __setitem__(self, key: Union[int, str, slice], value: Any) -> None: + if self._index: + # Following hdmf, VectorIndex is the thing that knows how to do the slicing + self._index[key] = value + else: + self.value[key] = value + + def __getattr__(self, item: str) -> Any: + """ + Forward getattr to ``value`` + """ + try: + return BaseModel.__getattr__(self, item) + except AttributeError as e: + try: + return getattr(self.value, item) + except AttributeError: + raise e from None + + def __len__(self) -> int: + """ + Use index as length, if present + """ + if self._index: + return len(self._index) + else: + return len(self.value) + + +class TimeSeriesReferenceVectorDataMixin(VectorDataMixin): + """ + Mixin class for TimeSeriesReferenceVectorData - + very simple, just indexing the given timeseries object. + + These shouldn't have additional fields in them, just the three columns + for index, span, and timeseries + """ + + idx_start: NDArray[Any, int] + count: NDArray[Any, int] + timeseries: NDArray[Any, BaseModel] + + @model_validator(mode="after") + def ensure_equal_length(self) -> "TimeSeriesReferenceVectorDataMixin": + assert len(self.idx_start) == len(self.timeseries) == len(self.count), ( + f"Columns have differing lengths: idx: {len(self.idx_start)}, count: {len(self.count)}," + f" timeseries: {len(self.timeseries)}" + ) + return self + + def __len__(self) -> int: + """Since we have ensured equal length, just return idx_start""" + return len(self.idx_start) + + @overload + def _slice_helper(self, item: int) -> slice: ... + + @overload + def _slice_helper(self, item: slice) -> List[slice]: ... + + def _slice_helper(self, item: Union[int, slice]) -> Union[slice, List[slice]]: + if isinstance(item, (int, np.integer)): + return slice(self.idx_start[item], self.idx_start[item] + self.count[item]) + else: + starts = self.idx_start[item] + ends = starts + self.count[item] + return [slice(start, end) for start, end in zip(starts, ends)] + + def __getitem__(self, item: Union[int, slice, Iterable]) -> Any: + if self._index is not None: + raise NotImplementedError( + "VectorIndexing with TimeSeriesReferenceVectorData is not supported because it is" + " never done in the core schema." + ) + + if isinstance(item, (int, np.integer)): + return self.timeseries[self._slice_helper(item)] + elif isinstance(item, slice): + return [self.timeseries[subitem] for subitem in self._slice_helper(item)] + elif isinstance(item, Iterable): + return [self.timeseries[self._slice_helper(subitem)] for subitem in item] + else: + raise ValueError( + f"Dont know how to index with {item}, must be an int, slice, or iterable" + ) + + def __setitem__(self, key: Union[int, slice, Iterable], value: Any) -> None: + if self._index is not None: + raise NotImplementedError( + "VectorIndexing with TimeSeriesReferenceVectorData is not supported because it is" + " never done in the core schema." + ) + if isinstance(key, (int, np.integer)): + self.timeseries[self._slice_helper(key)] = value + elif isinstance(key, slice): + for subitem in self._slice_helper(key): + self.timeseries[subitem] = value + elif isinstance(key, Iterable): + for subitem in key: + self.timeseries[self._slice_helper(subitem)] = value + else: + raise ValueError( + f"Dont know how to index with {key}, must be an int, slice, or iterable" + ) + + linkml_meta = LinkMLMeta( { "annotations": { @@ -78,7 +217,7 @@ class NWBData(Data): name: str = Field(...) -class TimeSeriesReferenceVectorData(VectorData): +class TimeSeriesReferenceVectorData(TimeSeriesReferenceVectorDataMixin, VectorData): """ Column storing references to a TimeSeries (rows). For each TimeSeries this VectorData column stores the start_index and count to indicate the range in time to be selected as well as an object reference to the TimeSeries. """ diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_behavior.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_behavior.py index 7251865..98282c5 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_behavior.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_behavior.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_device.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_device.py index f59deb8..f54c25e 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_device.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_device.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_ecephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_ecephys.py index 30e8b3e..de74f33 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_ecephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_ecephys.py @@ -44,6 +44,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_epoch.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_epoch.py index 1161d72..c4415c8 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_epoch.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_epoch.py @@ -37,6 +37,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_file.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_file.py index b74e8b8..8ddb92c 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_file.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_file.py @@ -50,6 +50,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_icephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_icephys.py index 11318b3..cd08504 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_icephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_icephys.py @@ -50,6 +50,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_image.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_image.py index 631f809..c792b06 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_image.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_image.py @@ -29,6 +29,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_misc.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_misc.py index 0828ebf..7c6183f 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_misc.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_misc.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_ogen.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_ogen.py index da627b1..d9184d4 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_ogen.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_ogen.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_ophys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_ophys.py index 2871455..96a8013 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_ophys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_ophys.py @@ -50,6 +50,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_retinotopy.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_retinotopy.py index 825df96..1b06207 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_retinotopy.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/core_nwb_retinotopy.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/namespace.py index bc7052a..ecb9186 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_4_0/namespace.py @@ -181,6 +181,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_base.py index 8ab4e6f..7973568 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_base.py @@ -8,13 +8,28 @@ import numpy as np from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container from numpydantic import NDArray, Shape from ...hdmf_common.v1_5_0.hdmf_common_table import VectorData, DynamicTable -from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar +from typing import ( + Any, + ClassVar, + List, + Literal, + Dict, + Optional, + Union, + overload, + Iterable, + Tuple, + Annotated, + Type, + TypeVar, +) from pydantic import ( BaseModel, ConfigDict, Field, RootModel, field_validator, + model_validator, ValidationInfo, BeforeValidator, ) @@ -37,6 +52,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} @@ -57,6 +81,135 @@ class LinkMLMeta(RootModel): NUMPYDANTIC_VERSION = "1.2.1" + +class VectorDataMixin(BaseModel): + """ + Mixin class to give VectorData indexing abilities + """ + + _index: Optional["VectorIndex"] = None + + # redefined in `VectorData`, but included here for testing and type checking + value: Optional[NDArray] = None + + def __init__(self, value: Optional[NDArray] = None, **kwargs): + if value is not None and "value" not in kwargs: + kwargs["value"] = value + super().__init__(**kwargs) + + def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any: + if self._index: + # Following hdmf, VectorIndex is the thing that knows how to do the slicing + return self._index[item] + else: + return self.value[item] + + def __setitem__(self, key: Union[int, str, slice], value: Any) -> None: + if self._index: + # Following hdmf, VectorIndex is the thing that knows how to do the slicing + self._index[key] = value + else: + self.value[key] = value + + def __getattr__(self, item: str) -> Any: + """ + Forward getattr to ``value`` + """ + try: + return BaseModel.__getattr__(self, item) + except AttributeError as e: + try: + return getattr(self.value, item) + except AttributeError: + raise e from None + + def __len__(self) -> int: + """ + Use index as length, if present + """ + if self._index: + return len(self._index) + else: + return len(self.value) + + +class TimeSeriesReferenceVectorDataMixin(VectorDataMixin): + """ + Mixin class for TimeSeriesReferenceVectorData - + very simple, just indexing the given timeseries object. + + These shouldn't have additional fields in them, just the three columns + for index, span, and timeseries + """ + + idx_start: NDArray[Any, int] + count: NDArray[Any, int] + timeseries: NDArray[Any, BaseModel] + + @model_validator(mode="after") + def ensure_equal_length(self) -> "TimeSeriesReferenceVectorDataMixin": + assert len(self.idx_start) == len(self.timeseries) == len(self.count), ( + f"Columns have differing lengths: idx: {len(self.idx_start)}, count: {len(self.count)}," + f" timeseries: {len(self.timeseries)}" + ) + return self + + def __len__(self) -> int: + """Since we have ensured equal length, just return idx_start""" + return len(self.idx_start) + + @overload + def _slice_helper(self, item: int) -> slice: ... + + @overload + def _slice_helper(self, item: slice) -> List[slice]: ... + + def _slice_helper(self, item: Union[int, slice]) -> Union[slice, List[slice]]: + if isinstance(item, (int, np.integer)): + return slice(self.idx_start[item], self.idx_start[item] + self.count[item]) + else: + starts = self.idx_start[item] + ends = starts + self.count[item] + return [slice(start, end) for start, end in zip(starts, ends)] + + def __getitem__(self, item: Union[int, slice, Iterable]) -> Any: + if self._index is not None: + raise NotImplementedError( + "VectorIndexing with TimeSeriesReferenceVectorData is not supported because it is" + " never done in the core schema." + ) + + if isinstance(item, (int, np.integer)): + return self.timeseries[self._slice_helper(item)] + elif isinstance(item, slice): + return [self.timeseries[subitem] for subitem in self._slice_helper(item)] + elif isinstance(item, Iterable): + return [self.timeseries[self._slice_helper(subitem)] for subitem in item] + else: + raise ValueError( + f"Dont know how to index with {item}, must be an int, slice, or iterable" + ) + + def __setitem__(self, key: Union[int, slice, Iterable], value: Any) -> None: + if self._index is not None: + raise NotImplementedError( + "VectorIndexing with TimeSeriesReferenceVectorData is not supported because it is" + " never done in the core schema." + ) + if isinstance(key, (int, np.integer)): + self.timeseries[self._slice_helper(key)] = value + elif isinstance(key, slice): + for subitem in self._slice_helper(key): + self.timeseries[subitem] = value + elif isinstance(key, Iterable): + for subitem in key: + self.timeseries[self._slice_helper(subitem)] = value + else: + raise ValueError( + f"Dont know how to index with {key}, must be an int, slice, or iterable" + ) + + ModelType = TypeVar("ModelType", bound=Type[BaseModel]) @@ -102,7 +255,7 @@ class NWBData(Data): name: str = Field(...) -class TimeSeriesReferenceVectorData(VectorData): +class TimeSeriesReferenceVectorData(TimeSeriesReferenceVectorDataMixin, VectorData): """ Column storing references to a TimeSeries (rows). For each TimeSeries this VectorData column stores the start_index and count to indicate the range in time to be selected as well as an object reference to the TimeSeries. """ diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_behavior.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_behavior.py index c295739..86b4bc0 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_behavior.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_behavior.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_device.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_device.py index 53128f3..4b214a9 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_device.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_device.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_ecephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_ecephys.py index f5e12e0..7c60b61 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_ecephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_ecephys.py @@ -44,6 +44,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_epoch.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_epoch.py index 26b4717..6091bbf 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_epoch.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_epoch.py @@ -37,6 +37,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_file.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_file.py index dc3dd77..e09f4fb 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_file.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_file.py @@ -51,6 +51,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_icephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_icephys.py index e802bcf..a7175f4 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_icephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_icephys.py @@ -50,6 +50,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_image.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_image.py index d92729b..8dbbb44 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_image.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_image.py @@ -35,6 +35,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_misc.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_misc.py index 1459133..e463240 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_misc.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_misc.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_ogen.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_ogen.py index 0cfb470..f397977 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_ogen.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_ogen.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_ophys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_ophys.py index fbc5c57..c80c328 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_ophys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_ophys.py @@ -50,6 +50,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_retinotopy.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_retinotopy.py index 7a3b066..90bd8c1 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_retinotopy.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/core_nwb_retinotopy.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/namespace.py index ce0dfe0..ec00173 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_5_0/namespace.py @@ -182,6 +182,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_base.py index 3151433..6cf4107 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_base.py @@ -8,13 +8,28 @@ import numpy as np from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container from numpydantic import NDArray, Shape from ...hdmf_common.v1_5_0.hdmf_common_table import VectorData, DynamicTable -from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar +from typing import ( + Any, + ClassVar, + List, + Literal, + Dict, + Optional, + Union, + overload, + Iterable, + Tuple, + Annotated, + Type, + TypeVar, +) from pydantic import ( BaseModel, ConfigDict, Field, RootModel, field_validator, + model_validator, ValidationInfo, BeforeValidator, ) @@ -37,6 +52,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} @@ -57,6 +81,135 @@ class LinkMLMeta(RootModel): NUMPYDANTIC_VERSION = "1.2.1" + +class VectorDataMixin(BaseModel): + """ + Mixin class to give VectorData indexing abilities + """ + + _index: Optional["VectorIndex"] = None + + # redefined in `VectorData`, but included here for testing and type checking + value: Optional[NDArray] = None + + def __init__(self, value: Optional[NDArray] = None, **kwargs): + if value is not None and "value" not in kwargs: + kwargs["value"] = value + super().__init__(**kwargs) + + def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any: + if self._index: + # Following hdmf, VectorIndex is the thing that knows how to do the slicing + return self._index[item] + else: + return self.value[item] + + def __setitem__(self, key: Union[int, str, slice], value: Any) -> None: + if self._index: + # Following hdmf, VectorIndex is the thing that knows how to do the slicing + self._index[key] = value + else: + self.value[key] = value + + def __getattr__(self, item: str) -> Any: + """ + Forward getattr to ``value`` + """ + try: + return BaseModel.__getattr__(self, item) + except AttributeError as e: + try: + return getattr(self.value, item) + except AttributeError: + raise e from None + + def __len__(self) -> int: + """ + Use index as length, if present + """ + if self._index: + return len(self._index) + else: + return len(self.value) + + +class TimeSeriesReferenceVectorDataMixin(VectorDataMixin): + """ + Mixin class for TimeSeriesReferenceVectorData - + very simple, just indexing the given timeseries object. + + These shouldn't have additional fields in them, just the three columns + for index, span, and timeseries + """ + + idx_start: NDArray[Any, int] + count: NDArray[Any, int] + timeseries: NDArray[Any, BaseModel] + + @model_validator(mode="after") + def ensure_equal_length(self) -> "TimeSeriesReferenceVectorDataMixin": + assert len(self.idx_start) == len(self.timeseries) == len(self.count), ( + f"Columns have differing lengths: idx: {len(self.idx_start)}, count: {len(self.count)}," + f" timeseries: {len(self.timeseries)}" + ) + return self + + def __len__(self) -> int: + """Since we have ensured equal length, just return idx_start""" + return len(self.idx_start) + + @overload + def _slice_helper(self, item: int) -> slice: ... + + @overload + def _slice_helper(self, item: slice) -> List[slice]: ... + + def _slice_helper(self, item: Union[int, slice]) -> Union[slice, List[slice]]: + if isinstance(item, (int, np.integer)): + return slice(self.idx_start[item], self.idx_start[item] + self.count[item]) + else: + starts = self.idx_start[item] + ends = starts + self.count[item] + return [slice(start, end) for start, end in zip(starts, ends)] + + def __getitem__(self, item: Union[int, slice, Iterable]) -> Any: + if self._index is not None: + raise NotImplementedError( + "VectorIndexing with TimeSeriesReferenceVectorData is not supported because it is" + " never done in the core schema." + ) + + if isinstance(item, (int, np.integer)): + return self.timeseries[self._slice_helper(item)] + elif isinstance(item, slice): + return [self.timeseries[subitem] for subitem in self._slice_helper(item)] + elif isinstance(item, Iterable): + return [self.timeseries[self._slice_helper(subitem)] for subitem in item] + else: + raise ValueError( + f"Dont know how to index with {item}, must be an int, slice, or iterable" + ) + + def __setitem__(self, key: Union[int, slice, Iterable], value: Any) -> None: + if self._index is not None: + raise NotImplementedError( + "VectorIndexing with TimeSeriesReferenceVectorData is not supported because it is" + " never done in the core schema." + ) + if isinstance(key, (int, np.integer)): + self.timeseries[self._slice_helper(key)] = value + elif isinstance(key, slice): + for subitem in self._slice_helper(key): + self.timeseries[subitem] = value + elif isinstance(key, Iterable): + for subitem in key: + self.timeseries[self._slice_helper(subitem)] = value + else: + raise ValueError( + f"Dont know how to index with {key}, must be an int, slice, or iterable" + ) + + ModelType = TypeVar("ModelType", bound=Type[BaseModel]) @@ -102,7 +255,7 @@ class NWBData(Data): name: str = Field(...) -class TimeSeriesReferenceVectorData(VectorData): +class TimeSeriesReferenceVectorData(TimeSeriesReferenceVectorDataMixin, VectorData): """ Column storing references to a TimeSeries (rows). For each TimeSeries this VectorData column stores the start_index and count to indicate the range in time to be selected as well as an object reference to the TimeSeries. """ diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_behavior.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_behavior.py index 08d5d2b..508ddf8 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_behavior.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_behavior.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_device.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_device.py index deeda97..544b533 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_device.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_device.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_ecephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_ecephys.py index 40d3c1a..2c241ec 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_ecephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_ecephys.py @@ -44,6 +44,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_epoch.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_epoch.py index 92e28fa..6095a6f 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_epoch.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_epoch.py @@ -37,6 +37,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_file.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_file.py index be8be33..19bdf9c 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_file.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_file.py @@ -51,6 +51,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_icephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_icephys.py index e6cb759..731a452 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_icephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_icephys.py @@ -50,6 +50,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_image.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_image.py index 07a02dc..ed4d986 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_image.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_image.py @@ -35,6 +35,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_misc.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_misc.py index 93d732d..18065b1 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_misc.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_misc.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_ogen.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_ogen.py index 66baef6..0371f5d 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_ogen.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_ogen.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_ophys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_ophys.py index cfc2f60..dc54f7c 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_ophys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_ophys.py @@ -50,6 +50,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_retinotopy.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_retinotopy.py index 75922c5..d454105 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_retinotopy.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/core_nwb_retinotopy.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/namespace.py index 6cb7862..c0c5da0 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_6_0_alpha/namespace.py @@ -184,6 +184,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_base.py index f84cee5..430e080 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_base.py @@ -1,20 +1,29 @@ from __future__ import annotations -from datetime import datetime, date -from decimal import Decimal -from enum import Enum -import re -import sys import numpy as np from ...hdmf_common.v1_8_0.hdmf_common_base import Data, Container from numpydantic import NDArray, Shape from ...hdmf_common.v1_8_0.hdmf_common_table import VectorData, DynamicTable -from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar +from typing import ( + Any, + ClassVar, + List, + Literal, + Dict, + Optional, + Union, + overload, + Iterable, + Tuple, + Annotated, + Type, + TypeVar, +) from pydantic import ( BaseModel, ConfigDict, Field, RootModel, - field_validator, + model_validator, ValidationInfo, BeforeValidator, ) @@ -37,6 +46,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} @@ -57,6 +75,135 @@ class LinkMLMeta(RootModel): NUMPYDANTIC_VERSION = "1.2.1" + +class VectorDataMixin(BaseModel): + """ + Mixin class to give VectorData indexing abilities + """ + + _index: Optional["VectorIndex"] = None + + # redefined in `VectorData`, but included here for testing and type checking + value: Optional[NDArray] = None + + def __init__(self, value: Optional[NDArray] = None, **kwargs): + if value is not None and "value" not in kwargs: + kwargs["value"] = value + super().__init__(**kwargs) + + def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any: + if self._index: + # Following hdmf, VectorIndex is the thing that knows how to do the slicing + return self._index[item] + else: + return self.value[item] + + def __setitem__(self, key: Union[int, str, slice], value: Any) -> None: + if self._index: + # Following hdmf, VectorIndex is the thing that knows how to do the slicing + self._index[key] = value + else: + self.value[key] = value + + def __getattr__(self, item: str) -> Any: + """ + Forward getattr to ``value`` + """ + try: + return BaseModel.__getattr__(self, item) + except AttributeError as e: + try: + return getattr(self.value, item) + except AttributeError: + raise e from None + + def __len__(self) -> int: + """ + Use index as length, if present + """ + if self._index: + return len(self._index) + else: + return len(self.value) + + +class TimeSeriesReferenceVectorDataMixin(VectorDataMixin): + """ + Mixin class for TimeSeriesReferenceVectorData - + very simple, just indexing the given timeseries object. + + These shouldn't have additional fields in them, just the three columns + for index, span, and timeseries + """ + + idx_start: NDArray[Any, int] + count: NDArray[Any, int] + timeseries: NDArray[Any, BaseModel] + + @model_validator(mode="after") + def ensure_equal_length(self) -> "TimeSeriesReferenceVectorDataMixin": + assert len(self.idx_start) == len(self.timeseries) == len(self.count), ( + f"Columns have differing lengths: idx: {len(self.idx_start)}, count: {len(self.count)}," + f" timeseries: {len(self.timeseries)}" + ) + return self + + def __len__(self) -> int: + """Since we have ensured equal length, just return idx_start""" + return len(self.idx_start) + + @overload + def _slice_helper(self, item: int) -> slice: ... + + @overload + def _slice_helper(self, item: slice) -> List[slice]: ... + + def _slice_helper(self, item: Union[int, slice]) -> Union[slice, List[slice]]: + if isinstance(item, (int, np.integer)): + return slice(self.idx_start[item], self.idx_start[item] + self.count[item]) + else: + starts = self.idx_start[item] + ends = starts + self.count[item] + return [slice(start, end) for start, end in zip(starts, ends)] + + def __getitem__(self, item: Union[int, slice, Iterable]) -> Any: + if self._index is not None: + raise NotImplementedError( + "VectorIndexing with TimeSeriesReferenceVectorData is not supported because it is" + " never done in the core schema." + ) + + if isinstance(item, (int, np.integer)): + return self.timeseries[self._slice_helper(item)] + elif isinstance(item, slice): + return [self.timeseries[subitem] for subitem in self._slice_helper(item)] + elif isinstance(item, Iterable): + return [self.timeseries[self._slice_helper(subitem)] for subitem in item] + else: + raise ValueError( + f"Dont know how to index with {item}, must be an int, slice, or iterable" + ) + + def __setitem__(self, key: Union[int, slice, Iterable], value: Any) -> None: + if self._index is not None: + raise NotImplementedError( + "VectorIndexing with TimeSeriesReferenceVectorData is not supported because it is" + " never done in the core schema." + ) + if isinstance(key, (int, np.integer)): + self.timeseries[self._slice_helper(key)] = value + elif isinstance(key, slice): + for subitem in self._slice_helper(key): + self.timeseries[subitem] = value + elif isinstance(key, Iterable): + for subitem in key: + self.timeseries[self._slice_helper(subitem)] = value + else: + raise ValueError( + f"Dont know how to index with {key}, must be an int, slice, or iterable" + ) + + ModelType = TypeVar("ModelType", bound=Type[BaseModel]) @@ -102,7 +249,7 @@ class NWBData(Data): name: str = Field(...) -class TimeSeriesReferenceVectorData(VectorData): +class TimeSeriesReferenceVectorData(TimeSeriesReferenceVectorDataMixin, VectorData): """ Column storing references to a TimeSeries (rows). For each TimeSeries this VectorData column stores the start_index and count to indicate the range in time to be selected as well as an object reference to the TimeSeries. """ diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_behavior.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_behavior.py index e8c8a80..780e83a 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_behavior.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_behavior.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_device.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_device.py index 0abc50a..24e2e67 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_device.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_device.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_ecephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_ecephys.py index aed71ed..17de2b5 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_ecephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_ecephys.py @@ -44,6 +44,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_epoch.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_epoch.py index 90c2524..d10191e 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_epoch.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_epoch.py @@ -37,6 +37,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_file.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_file.py index ef1a1e6..950faa5 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_file.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_file.py @@ -51,6 +51,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_icephys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_icephys.py index 93a555a..86754a8 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_icephys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_icephys.py @@ -50,6 +50,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_image.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_image.py index 69a8617..c2b5aff 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_image.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_image.py @@ -35,6 +35,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_misc.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_misc.py index edf6336..2739d41 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_misc.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_misc.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_ogen.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_ogen.py index d77dcba..881aea0 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_ogen.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_ogen.py @@ -34,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_ophys.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_ophys.py index 6e4b60f..04dcee9 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_ophys.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_ophys.py @@ -50,6 +50,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_retinotopy.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_retinotopy.py index 0942bac..1d8b514 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_retinotopy.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/core_nwb_retinotopy.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/namespace.py index 4f98b35..c6c0f39 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/core/v2_7_0/namespace.py @@ -185,6 +185,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_0/hdmf_common_sparse.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_0/hdmf_common_sparse.py index af77c6c..8cd8423 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_0/hdmf_common_sparse.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_0/hdmf_common_sparse.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_0/hdmf_common_table.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_0/hdmf_common_table.py index a37ac18..9d5b38f 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_0/hdmf_common_table.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_0/hdmf_common_table.py @@ -38,6 +38,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_0/namespace.py index 703fefe..d0a1b95 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_0/namespace.py @@ -42,6 +42,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_2/hdmf_common_sparse.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_2/hdmf_common_sparse.py index 8c05020..f0d3be3 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_2/hdmf_common_sparse.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_2/hdmf_common_sparse.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_2/hdmf_common_table.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_2/hdmf_common_table.py index 2a0c39a..825e522 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_2/hdmf_common_table.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_2/hdmf_common_table.py @@ -38,6 +38,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_2/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_2/namespace.py index a9507d4..13ff59e 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_2/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_2/namespace.py @@ -42,6 +42,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_3/hdmf_common_sparse.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_3/hdmf_common_sparse.py index c473269..7e9fa34 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_3/hdmf_common_sparse.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_3/hdmf_common_sparse.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_3/hdmf_common_table.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_3/hdmf_common_table.py index 57472fa..e837810 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_3/hdmf_common_table.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_3/hdmf_common_table.py @@ -38,6 +38,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_3/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_3/namespace.py index e8dac61..284e138 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_3/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_1_3/namespace.py @@ -42,6 +42,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/hdmf_common_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/hdmf_common_base.py index 1d657d9..0880d00 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/hdmf_common_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/hdmf_common_base.py @@ -26,6 +26,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/hdmf_common_sparse.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/hdmf_common_sparse.py index 6cf3e21..0029140 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/hdmf_common_sparse.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/hdmf_common_sparse.py @@ -27,6 +27,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/hdmf_common_table.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/hdmf_common_table.py index cbefb40..7c232b0 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/hdmf_common_table.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/hdmf_common_table.py @@ -39,6 +39,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/namespace.py index 62d22cb..7314aa8 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_0/namespace.py @@ -41,6 +41,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/hdmf_common_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/hdmf_common_base.py index e75baf7..60eea59 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/hdmf_common_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/hdmf_common_base.py @@ -26,6 +26,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/hdmf_common_sparse.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/hdmf_common_sparse.py index 62bc6ef..ebdac35 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/hdmf_common_sparse.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/hdmf_common_sparse.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/hdmf_common_table.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/hdmf_common_table.py index c62bd06..9c4e909 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/hdmf_common_table.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/hdmf_common_table.py @@ -39,6 +39,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/namespace.py index 55f5dc6..7691d2a 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_2_1/namespace.py @@ -41,6 +41,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_base.py index 83003ce..1752575 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_base.py @@ -26,6 +26,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_resources.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_resources.py index 57a1938..9331ccc 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_resources.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_resources.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_sparse.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_sparse.py index 3d4d4af..e01d80e 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_sparse.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_sparse.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_table.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_table.py index c0e6522..f77e052 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_table.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/hdmf_common_table.py @@ -39,6 +39,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/namespace.py index a2dcc70..ef79cd9 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_3_0/namespace.py @@ -43,6 +43,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/hdmf_common_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/hdmf_common_base.py index 3adb8b8..9d878a5 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/hdmf_common_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/hdmf_common_base.py @@ -26,6 +26,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/hdmf_common_sparse.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/hdmf_common_sparse.py index f304f3a..00a62c7 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/hdmf_common_sparse.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/hdmf_common_sparse.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/hdmf_common_table.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/hdmf_common_table.py index d3599bb..6514e14 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/hdmf_common_table.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/hdmf_common_table.py @@ -39,6 +39,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/namespace.py index db59f28..43432b8 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_4_0/namespace.py @@ -35,6 +35,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/hdmf_common_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/hdmf_common_base.py index 29c6ea2..5545403 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/hdmf_common_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/hdmf_common_base.py @@ -26,6 +26,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/hdmf_common_sparse.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/hdmf_common_sparse.py index e261b0a..f07bed2 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/hdmf_common_sparse.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/hdmf_common_sparse.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/hdmf_common_table.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/hdmf_common_table.py index 946d90f..b64b835 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/hdmf_common_table.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/hdmf_common_table.py @@ -39,6 +39,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/namespace.py index b9cf9ac..6d03d3d 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_0/namespace.py @@ -36,6 +36,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/hdmf_common_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/hdmf_common_base.py index e360db2..737fa66 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/hdmf_common_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/hdmf_common_base.py @@ -26,6 +26,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/hdmf_common_sparse.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/hdmf_common_sparse.py index 30f0c4b..41d0d3a 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/hdmf_common_sparse.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/hdmf_common_sparse.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/hdmf_common_table.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/hdmf_common_table.py index 95d594e..3593099 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/hdmf_common_table.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/hdmf_common_table.py @@ -39,6 +39,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/namespace.py index 836122e..1676f7c 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_5_1/namespace.py @@ -36,6 +36,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/hdmf_common_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/hdmf_common_base.py index 49293d1..21354d9 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/hdmf_common_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/hdmf_common_base.py @@ -26,6 +26,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/hdmf_common_sparse.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/hdmf_common_sparse.py index ce6c0ed..bc4a505 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/hdmf_common_sparse.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/hdmf_common_sparse.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/hdmf_common_table.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/hdmf_common_table.py index ea5d7b1..b5d6b93 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/hdmf_common_table.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/hdmf_common_table.py @@ -39,6 +39,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/namespace.py index 1dc832f..68060f7 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_6_0/namespace.py @@ -36,6 +36,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/hdmf_common_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/hdmf_common_base.py index 51a093f..ec81b87 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/hdmf_common_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/hdmf_common_base.py @@ -26,6 +26,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/hdmf_common_sparse.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/hdmf_common_sparse.py index f59d4a7..3bfd4a8 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/hdmf_common_sparse.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/hdmf_common_sparse.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/hdmf_common_table.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/hdmf_common_table.py index 3c4c993..51820ad 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/hdmf_common_table.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/hdmf_common_table.py @@ -39,6 +39,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/namespace.py index 7d70e39..56b9f0d 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_7_0/namespace.py @@ -36,6 +36,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/hdmf_common_base.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/hdmf_common_base.py index f125a10..0e61a5c 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/hdmf_common_base.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/hdmf_common_base.py @@ -26,6 +26,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/hdmf_common_sparse.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/hdmf_common_sparse.py index 248869e..aef8124 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/hdmf_common_sparse.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/hdmf_common_sparse.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/hdmf_common_table.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/hdmf_common_table.py index 60bbadf..6104fd5 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/hdmf_common_table.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/hdmf_common_table.py @@ -1,12 +1,7 @@ from __future__ import annotations -from datetime import datetime, date -from decimal import Decimal -from enum import Enum -import re -import sys -from ...hdmf_common.v1_8_0.hdmf_common_base import Data, Container +from ...hdmf_common.v1_8_0.hdmf_common_base import Data import pandas as pd -from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Iterable, Tuple, overload +from typing import Any, ClassVar, List, Dict, Optional, Union, Iterable, Tuple, overload from pydantic import ( BaseModel, ConfigDict, @@ -39,6 +34,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} @@ -561,6 +565,32 @@ class AlignedDynamicTableMixin(DynamicTableMixin): df.set_index((self.name, "id"), drop=True, inplace=True) return df + @model_validator(mode="before") + @classmethod + def create_categories(cls, model: Dict[str, Any]) -> Dict: + """ + Construct categories from arguments. + + the model dict is ordered after python3.6, so we can use that minus + anything in :attr:`.NON_COLUMN_FIELDS` to determine order implied from passage order + """ + if "categories" not in model: + categories = [ + k for k in model if k not in cls.NON_CATEGORY_FIELDS and not k.endswith("_index") + ] + model["categories"] = categories + else: + # add any columns not explicitly given an order at the end + categories = [ + k + for k in model + if k not in cls.NON_COLUMN_FIELDS + and not k.endswith("_index") + and k not in model["categories"] + ] + model["categories"].extend(categories) + return model + linkml_meta = LinkMLMeta( { diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/namespace.py index 8b9bf5b..66dcf89 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_common/v1_8_0/namespace.py @@ -36,6 +36,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_1_0/hdmf_experimental_experimental.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_1_0/hdmf_experimental_experimental.py index 913bcfc..9a95aea 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_1_0/hdmf_experimental_experimental.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_1_0/hdmf_experimental_experimental.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_1_0/hdmf_experimental_resources.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_1_0/hdmf_experimental_resources.py index 6b1a964..fdeb151 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_1_0/hdmf_experimental_resources.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_1_0/hdmf_experimental_resources.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_1_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_1_0/namespace.py index 7ea10f7..a9c5e62 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_1_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_1_0/namespace.py @@ -44,6 +44,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_2_0/hdmf_experimental_experimental.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_2_0/hdmf_experimental_experimental.py index 63f582a..01b7693 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_2_0/hdmf_experimental_experimental.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_2_0/hdmf_experimental_experimental.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_2_0/hdmf_experimental_resources.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_2_0/hdmf_experimental_resources.py index 810f8ef..81b0840 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_2_0/hdmf_experimental_resources.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_2_0/hdmf_experimental_resources.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_2_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_2_0/namespace.py index 1345536..5c8e028 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_2_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_2_0/namespace.py @@ -45,6 +45,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_3_0/hdmf_experimental_experimental.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_3_0/hdmf_experimental_experimental.py index 92d347a..effed9e 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_3_0/hdmf_experimental_experimental.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_3_0/hdmf_experimental_experimental.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_3_0/hdmf_experimental_resources.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_3_0/hdmf_experimental_resources.py index 4404c7f..52e554a 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_3_0/hdmf_experimental_resources.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_3_0/hdmf_experimental_resources.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_3_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_3_0/namespace.py index 8361004..bf78d15 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_3_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_3_0/namespace.py @@ -45,6 +45,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_4_0/hdmf_experimental_experimental.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_4_0/hdmf_experimental_experimental.py index 0402b68..49f56f2 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_4_0/hdmf_experimental_experimental.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_4_0/hdmf_experimental_experimental.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_4_0/hdmf_experimental_resources.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_4_0/hdmf_experimental_resources.py index 7eef961..acfc7df 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_4_0/hdmf_experimental_resources.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_4_0/hdmf_experimental_resources.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_4_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_4_0/namespace.py index c642308..2422a59 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_4_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_4_0/namespace.py @@ -46,6 +46,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_5_0/hdmf_experimental_experimental.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_5_0/hdmf_experimental_experimental.py index 57e1a37..263e7b2 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_5_0/hdmf_experimental_experimental.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_5_0/hdmf_experimental_experimental.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_5_0/hdmf_experimental_resources.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_5_0/hdmf_experimental_resources.py index 0adfcc3..9cbbb79 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_5_0/hdmf_experimental_resources.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_5_0/hdmf_experimental_resources.py @@ -28,6 +28,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {} diff --git a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_5_0/namespace.py b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_5_0/namespace.py index 8f32985..e35c690 100644 --- a/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_5_0/namespace.py +++ b/nwb_linkml/src/nwb_linkml/models/pydantic/hdmf_experimental/v0_5_0/namespace.py @@ -46,6 +46,15 @@ class ConfiguredBaseModel(BaseModel): ) object_id: Optional[str] = Field(None, description="Unique UUID for each object") + def __getitem__(self, val: Union[int, slice]) -> Any: + """Try and get a value from value or "data" if we have it""" + if hasattr(self, "value") and self.value is not None: + return self.value[val] + elif hasattr(self, "data") and self.data is not None: + return self.data[val] + else: + raise KeyError("No value or data field to index from") + class LinkMLMeta(RootModel): root: Dict[str, Any] = {}