mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2024-11-10 00:34:29 +00:00
update hdmf common table
This commit is contained in:
parent
374bd8971d
commit
652ddb3b48
5 changed files with 45 additions and 45 deletions
|
@ -57,21 +57,21 @@ class VectorDataMixin(BaseModel):
|
||||||
_index: Optional["VectorIndex"] = None
|
_index: Optional["VectorIndex"] = None
|
||||||
|
|
||||||
# redefined in `VectorData`, but included here for testing and type checking
|
# redefined in `VectorData`, but included here for testing and type checking
|
||||||
array: Optional[NDArray] = None
|
value: Optional[NDArray] = None
|
||||||
|
|
||||||
def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any:
|
def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any:
|
||||||
if self._index:
|
if self._index:
|
||||||
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
||||||
return self._index[item]
|
return self._index[item]
|
||||||
else:
|
else:
|
||||||
return self.array[item]
|
return self.value[item]
|
||||||
|
|
||||||
def __setitem__(self, key: Union[int, str, slice], value: Any) -> None:
|
def __setitem__(self, key: Union[int, str, slice], value: Any) -> None:
|
||||||
if self._index:
|
if self._index:
|
||||||
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
||||||
self._index[key] = value
|
self._index[key] = value
|
||||||
else:
|
else:
|
||||||
self.array[key] = value
|
self.value[key] = value
|
||||||
|
|
||||||
|
|
||||||
class VectorIndexMixin(BaseModel):
|
class VectorIndexMixin(BaseModel):
|
||||||
|
@ -80,7 +80,7 @@ class VectorIndexMixin(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# redefined in `VectorData`, but included here for testing and type checking
|
# redefined in `VectorData`, but included here for testing and type checking
|
||||||
array: Optional[NDArray] = None
|
value: Optional[NDArray] = None
|
||||||
target: Optional["VectorData"] = None
|
target: Optional["VectorData"] = None
|
||||||
|
|
||||||
def _getitem_helper(self, arg: int) -> Union[list, NDArray]:
|
def _getitem_helper(self, arg: int) -> Union[list, NDArray]:
|
||||||
|
@ -88,18 +88,18 @@ class VectorIndexMixin(BaseModel):
|
||||||
Mimicking :func:`hdmf.common.table.VectorIndex.__getitem_helper`
|
Mimicking :func:`hdmf.common.table.VectorIndex.__getitem_helper`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
start = 0 if arg == 0 else self.array[arg - 1]
|
start = 0 if arg == 0 else self.value[arg - 1]
|
||||||
end = self.array[arg]
|
end = self.value[arg]
|
||||||
return self.target.array[slice(start, end)]
|
return self.target.array[slice(start, end)]
|
||||||
|
|
||||||
def __getitem__(self, item: Union[int, slice]) -> Any:
|
def __getitem__(self, item: Union[int, slice]) -> Any:
|
||||||
if self.target is None:
|
if self.target is None:
|
||||||
return self.array[item]
|
return self.value[item]
|
||||||
elif type(self.target).__name__ == "VectorData":
|
elif type(self.target).__name__ == "VectorData":
|
||||||
if isinstance(item, int):
|
if isinstance(item, int):
|
||||||
return self._getitem_helper(item)
|
return self._getitem_helper(item)
|
||||||
else:
|
else:
|
||||||
idx = range(*item.indices(len(self.array)))
|
idx = range(*item.indices(len(self.value)))
|
||||||
return [self._getitem_helper(i) for i in idx]
|
return [self._getitem_helper(i) for i in idx]
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError("DynamicTableRange not supported yet")
|
raise NotImplementedError("DynamicTableRange not supported yet")
|
||||||
|
@ -109,7 +109,7 @@ class VectorIndexMixin(BaseModel):
|
||||||
# VectorIndex is the thing that knows how to do the slicing
|
# VectorIndex is the thing that knows how to do the slicing
|
||||||
self._index[key] = value
|
self._index[key] = value
|
||||||
else:
|
else:
|
||||||
self.array[key] = value
|
self.value[key] = value
|
||||||
|
|
||||||
|
|
||||||
class DynamicTableMixin(BaseModel):
|
class DynamicTableMixin(BaseModel):
|
||||||
|
|
|
@ -57,21 +57,21 @@ class VectorDataMixin(BaseModel):
|
||||||
_index: Optional["VectorIndex"] = None
|
_index: Optional["VectorIndex"] = None
|
||||||
|
|
||||||
# redefined in `VectorData`, but included here for testing and type checking
|
# redefined in `VectorData`, but included here for testing and type checking
|
||||||
array: Optional[NDArray] = None
|
value: Optional[NDArray] = None
|
||||||
|
|
||||||
def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any:
|
def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any:
|
||||||
if self._index:
|
if self._index:
|
||||||
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
||||||
return self._index[item]
|
return self._index[item]
|
||||||
else:
|
else:
|
||||||
return self.array[item]
|
return self.value[item]
|
||||||
|
|
||||||
def __setitem__(self, key: Union[int, str, slice], value: Any) -> None:
|
def __setitem__(self, key: Union[int, str, slice], value: Any) -> None:
|
||||||
if self._index:
|
if self._index:
|
||||||
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
||||||
self._index[key] = value
|
self._index[key] = value
|
||||||
else:
|
else:
|
||||||
self.array[key] = value
|
self.value[key] = value
|
||||||
|
|
||||||
|
|
||||||
class VectorIndexMixin(BaseModel):
|
class VectorIndexMixin(BaseModel):
|
||||||
|
@ -80,7 +80,7 @@ class VectorIndexMixin(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# redefined in `VectorData`, but included here for testing and type checking
|
# redefined in `VectorData`, but included here for testing and type checking
|
||||||
array: Optional[NDArray] = None
|
value: Optional[NDArray] = None
|
||||||
target: Optional["VectorData"] = None
|
target: Optional["VectorData"] = None
|
||||||
|
|
||||||
def _getitem_helper(self, arg: int) -> Union[list, NDArray]:
|
def _getitem_helper(self, arg: int) -> Union[list, NDArray]:
|
||||||
|
@ -88,18 +88,18 @@ class VectorIndexMixin(BaseModel):
|
||||||
Mimicking :func:`hdmf.common.table.VectorIndex.__getitem_helper`
|
Mimicking :func:`hdmf.common.table.VectorIndex.__getitem_helper`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
start = 0 if arg == 0 else self.array[arg - 1]
|
start = 0 if arg == 0 else self.value[arg - 1]
|
||||||
end = self.array[arg]
|
end = self.value[arg]
|
||||||
return self.target.array[slice(start, end)]
|
return self.target.array[slice(start, end)]
|
||||||
|
|
||||||
def __getitem__(self, item: Union[int, slice]) -> Any:
|
def __getitem__(self, item: Union[int, slice]) -> Any:
|
||||||
if self.target is None:
|
if self.target is None:
|
||||||
return self.array[item]
|
return self.value[item]
|
||||||
elif type(self.target).__name__ == "VectorData":
|
elif type(self.target).__name__ == "VectorData":
|
||||||
if isinstance(item, int):
|
if isinstance(item, int):
|
||||||
return self._getitem_helper(item)
|
return self._getitem_helper(item)
|
||||||
else:
|
else:
|
||||||
idx = range(*item.indices(len(self.array)))
|
idx = range(*item.indices(len(self.value)))
|
||||||
return [self._getitem_helper(i) for i in idx]
|
return [self._getitem_helper(i) for i in idx]
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError("DynamicTableRange not supported yet")
|
raise NotImplementedError("DynamicTableRange not supported yet")
|
||||||
|
@ -109,7 +109,7 @@ class VectorIndexMixin(BaseModel):
|
||||||
# VectorIndex is the thing that knows how to do the slicing
|
# VectorIndex is the thing that knows how to do the slicing
|
||||||
self._index[key] = value
|
self._index[key] = value
|
||||||
else:
|
else:
|
||||||
self.array[key] = value
|
self.value[key] = value
|
||||||
|
|
||||||
|
|
||||||
class DynamicTableMixin(BaseModel):
|
class DynamicTableMixin(BaseModel):
|
||||||
|
|
|
@ -57,21 +57,21 @@ class VectorDataMixin(BaseModel):
|
||||||
_index: Optional["VectorIndex"] = None
|
_index: Optional["VectorIndex"] = None
|
||||||
|
|
||||||
# redefined in `VectorData`, but included here for testing and type checking
|
# redefined in `VectorData`, but included here for testing and type checking
|
||||||
array: Optional[NDArray] = None
|
value: Optional[NDArray] = None
|
||||||
|
|
||||||
def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any:
|
def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any:
|
||||||
if self._index:
|
if self._index:
|
||||||
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
||||||
return self._index[item]
|
return self._index[item]
|
||||||
else:
|
else:
|
||||||
return self.array[item]
|
return self.value[item]
|
||||||
|
|
||||||
def __setitem__(self, key: Union[int, str, slice], value: Any) -> None:
|
def __setitem__(self, key: Union[int, str, slice], value: Any) -> None:
|
||||||
if self._index:
|
if self._index:
|
||||||
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
||||||
self._index[key] = value
|
self._index[key] = value
|
||||||
else:
|
else:
|
||||||
self.array[key] = value
|
self.value[key] = value
|
||||||
|
|
||||||
|
|
||||||
class VectorIndexMixin(BaseModel):
|
class VectorIndexMixin(BaseModel):
|
||||||
|
@ -80,7 +80,7 @@ class VectorIndexMixin(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# redefined in `VectorData`, but included here for testing and type checking
|
# redefined in `VectorData`, but included here for testing and type checking
|
||||||
array: Optional[NDArray] = None
|
value: Optional[NDArray] = None
|
||||||
target: Optional["VectorData"] = None
|
target: Optional["VectorData"] = None
|
||||||
|
|
||||||
def _getitem_helper(self, arg: int) -> Union[list, NDArray]:
|
def _getitem_helper(self, arg: int) -> Union[list, NDArray]:
|
||||||
|
@ -88,18 +88,18 @@ class VectorIndexMixin(BaseModel):
|
||||||
Mimicking :func:`hdmf.common.table.VectorIndex.__getitem_helper`
|
Mimicking :func:`hdmf.common.table.VectorIndex.__getitem_helper`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
start = 0 if arg == 0 else self.array[arg - 1]
|
start = 0 if arg == 0 else self.value[arg - 1]
|
||||||
end = self.array[arg]
|
end = self.value[arg]
|
||||||
return self.target.array[slice(start, end)]
|
return self.target.array[slice(start, end)]
|
||||||
|
|
||||||
def __getitem__(self, item: Union[int, slice]) -> Any:
|
def __getitem__(self, item: Union[int, slice]) -> Any:
|
||||||
if self.target is None:
|
if self.target is None:
|
||||||
return self.array[item]
|
return self.value[item]
|
||||||
elif type(self.target).__name__ == "VectorData":
|
elif type(self.target).__name__ == "VectorData":
|
||||||
if isinstance(item, int):
|
if isinstance(item, int):
|
||||||
return self._getitem_helper(item)
|
return self._getitem_helper(item)
|
||||||
else:
|
else:
|
||||||
idx = range(*item.indices(len(self.array)))
|
idx = range(*item.indices(len(self.value)))
|
||||||
return [self._getitem_helper(i) for i in idx]
|
return [self._getitem_helper(i) for i in idx]
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError("DynamicTableRange not supported yet")
|
raise NotImplementedError("DynamicTableRange not supported yet")
|
||||||
|
@ -109,7 +109,7 @@ class VectorIndexMixin(BaseModel):
|
||||||
# VectorIndex is the thing that knows how to do the slicing
|
# VectorIndex is the thing that knows how to do the slicing
|
||||||
self._index[key] = value
|
self._index[key] = value
|
||||||
else:
|
else:
|
||||||
self.array[key] = value
|
self.value[key] = value
|
||||||
|
|
||||||
|
|
||||||
class DynamicTableMixin(BaseModel):
|
class DynamicTableMixin(BaseModel):
|
||||||
|
|
|
@ -58,21 +58,21 @@ class VectorDataMixin(BaseModel):
|
||||||
_index: Optional["VectorIndex"] = None
|
_index: Optional["VectorIndex"] = None
|
||||||
|
|
||||||
# redefined in `VectorData`, but included here for testing and type checking
|
# redefined in `VectorData`, but included here for testing and type checking
|
||||||
array: Optional[NDArray] = None
|
value: Optional[NDArray] = None
|
||||||
|
|
||||||
def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any:
|
def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any:
|
||||||
if self._index:
|
if self._index:
|
||||||
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
||||||
return self._index[item]
|
return self._index[item]
|
||||||
else:
|
else:
|
||||||
return self.array[item]
|
return self.value[item]
|
||||||
|
|
||||||
def __setitem__(self, key: Union[int, str, slice], value: Any) -> None:
|
def __setitem__(self, key: Union[int, str, slice], value: Any) -> None:
|
||||||
if self._index:
|
if self._index:
|
||||||
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
||||||
self._index[key] = value
|
self._index[key] = value
|
||||||
else:
|
else:
|
||||||
self.array[key] = value
|
self.value[key] = value
|
||||||
|
|
||||||
|
|
||||||
class VectorIndexMixin(BaseModel):
|
class VectorIndexMixin(BaseModel):
|
||||||
|
@ -81,7 +81,7 @@ class VectorIndexMixin(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# redefined in `VectorData`, but included here for testing and type checking
|
# redefined in `VectorData`, but included here for testing and type checking
|
||||||
array: Optional[NDArray] = None
|
value: Optional[NDArray] = None
|
||||||
target: Optional["VectorData"] = None
|
target: Optional["VectorData"] = None
|
||||||
|
|
||||||
def _getitem_helper(self, arg: int) -> Union[list, NDArray]:
|
def _getitem_helper(self, arg: int) -> Union[list, NDArray]:
|
||||||
|
@ -89,18 +89,18 @@ class VectorIndexMixin(BaseModel):
|
||||||
Mimicking :func:`hdmf.common.table.VectorIndex.__getitem_helper`
|
Mimicking :func:`hdmf.common.table.VectorIndex.__getitem_helper`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
start = 0 if arg == 0 else self.array[arg - 1]
|
start = 0 if arg == 0 else self.value[arg - 1]
|
||||||
end = self.array[arg]
|
end = self.value[arg]
|
||||||
return self.target.array[slice(start, end)]
|
return self.target.array[slice(start, end)]
|
||||||
|
|
||||||
def __getitem__(self, item: Union[int, slice]) -> Any:
|
def __getitem__(self, item: Union[int, slice]) -> Any:
|
||||||
if self.target is None:
|
if self.target is None:
|
||||||
return self.array[item]
|
return self.value[item]
|
||||||
elif type(self.target).__name__ == "VectorData":
|
elif type(self.target).__name__ == "VectorData":
|
||||||
if isinstance(item, int):
|
if isinstance(item, int):
|
||||||
return self._getitem_helper(item)
|
return self._getitem_helper(item)
|
||||||
else:
|
else:
|
||||||
idx = range(*item.indices(len(self.array)))
|
idx = range(*item.indices(len(self.value)))
|
||||||
return [self._getitem_helper(i) for i in idx]
|
return [self._getitem_helper(i) for i in idx]
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError("DynamicTableRange not supported yet")
|
raise NotImplementedError("DynamicTableRange not supported yet")
|
||||||
|
@ -110,7 +110,7 @@ class VectorIndexMixin(BaseModel):
|
||||||
# VectorIndex is the thing that knows how to do the slicing
|
# VectorIndex is the thing that knows how to do the slicing
|
||||||
self._index[key] = value
|
self._index[key] = value
|
||||||
else:
|
else:
|
||||||
self.array[key] = value
|
self.value[key] = value
|
||||||
|
|
||||||
|
|
||||||
class DynamicTableMixin(BaseModel):
|
class DynamicTableMixin(BaseModel):
|
||||||
|
|
|
@ -58,21 +58,21 @@ class VectorDataMixin(BaseModel):
|
||||||
_index: Optional["VectorIndex"] = None
|
_index: Optional["VectorIndex"] = None
|
||||||
|
|
||||||
# redefined in `VectorData`, but included here for testing and type checking
|
# redefined in `VectorData`, but included here for testing and type checking
|
||||||
array: Optional[NDArray] = None
|
value: Optional[NDArray] = None
|
||||||
|
|
||||||
def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any:
|
def __getitem__(self, item: Union[str, int, slice, Tuple[Union[str, int, slice], ...]]) -> Any:
|
||||||
if self._index:
|
if self._index:
|
||||||
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
||||||
return self._index[item]
|
return self._index[item]
|
||||||
else:
|
else:
|
||||||
return self.array[item]
|
return self.value[item]
|
||||||
|
|
||||||
def __setitem__(self, key: Union[int, str, slice], value: Any) -> None:
|
def __setitem__(self, key: Union[int, str, slice], value: Any) -> None:
|
||||||
if self._index:
|
if self._index:
|
||||||
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
||||||
self._index[key] = value
|
self._index[key] = value
|
||||||
else:
|
else:
|
||||||
self.array[key] = value
|
self.value[key] = value
|
||||||
|
|
||||||
|
|
||||||
class VectorIndexMixin(BaseModel):
|
class VectorIndexMixin(BaseModel):
|
||||||
|
@ -81,7 +81,7 @@ class VectorIndexMixin(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# redefined in `VectorData`, but included here for testing and type checking
|
# redefined in `VectorData`, but included here for testing and type checking
|
||||||
array: Optional[NDArray] = None
|
value: Optional[NDArray] = None
|
||||||
target: Optional["VectorData"] = None
|
target: Optional["VectorData"] = None
|
||||||
|
|
||||||
def _getitem_helper(self, arg: int) -> Union[list, NDArray]:
|
def _getitem_helper(self, arg: int) -> Union[list, NDArray]:
|
||||||
|
@ -89,18 +89,18 @@ class VectorIndexMixin(BaseModel):
|
||||||
Mimicking :func:`hdmf.common.table.VectorIndex.__getitem_helper`
|
Mimicking :func:`hdmf.common.table.VectorIndex.__getitem_helper`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
start = 0 if arg == 0 else self.array[arg - 1]
|
start = 0 if arg == 0 else self.value[arg - 1]
|
||||||
end = self.array[arg]
|
end = self.value[arg]
|
||||||
return self.target.array[slice(start, end)]
|
return self.target.array[slice(start, end)]
|
||||||
|
|
||||||
def __getitem__(self, item: Union[int, slice]) -> Any:
|
def __getitem__(self, item: Union[int, slice]) -> Any:
|
||||||
if self.target is None:
|
if self.target is None:
|
||||||
return self.array[item]
|
return self.value[item]
|
||||||
elif type(self.target).__name__ == "VectorData":
|
elif type(self.target).__name__ == "VectorData":
|
||||||
if isinstance(item, int):
|
if isinstance(item, int):
|
||||||
return self._getitem_helper(item)
|
return self._getitem_helper(item)
|
||||||
else:
|
else:
|
||||||
idx = range(*item.indices(len(self.array)))
|
idx = range(*item.indices(len(self.value)))
|
||||||
return [self._getitem_helper(i) for i in idx]
|
return [self._getitem_helper(i) for i in idx]
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError("DynamicTableRange not supported yet")
|
raise NotImplementedError("DynamicTableRange not supported yet")
|
||||||
|
@ -110,7 +110,7 @@ class VectorIndexMixin(BaseModel):
|
||||||
# VectorIndex is the thing that knows how to do the slicing
|
# VectorIndex is the thing that knows how to do the slicing
|
||||||
self._index[key] = value
|
self._index[key] = value
|
||||||
else:
|
else:
|
||||||
self.array[key] = value
|
self.value[key] = value
|
||||||
|
|
||||||
|
|
||||||
class DynamicTableMixin(BaseModel):
|
class DynamicTableMixin(BaseModel):
|
||||||
|
|
Loading…
Reference in a new issue