mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2024-11-12 17:54:29 +00:00
fix name array -> value in hdmf mixins
This commit is contained in:
parent
0a150d6bc2
commit
374bd8971d
2 changed files with 9 additions and 10 deletions
|
@ -187,21 +187,21 @@ class VectorDataMixin(BaseModel):
|
|||
_index: Optional["VectorIndex"] = None
|
||||
|
||||
# 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:
|
||||
if self._index:
|
||||
# Following hdmf, VectorIndex is the thing that knows how to do the slicing
|
||||
return self._index[item]
|
||||
else:
|
||||
return self.array[item]
|
||||
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.array[key] = value
|
||||
self.value[key] = value
|
||||
|
||||
|
||||
class VectorIndexMixin(BaseModel):
|
||||
|
@ -210,7 +210,7 @@ class VectorIndexMixin(BaseModel):
|
|||
"""
|
||||
|
||||
# redefined in `VectorData`, but included here for testing and type checking
|
||||
array: Optional[NDArray] = None
|
||||
value: Optional[NDArray] = None
|
||||
target: Optional["VectorData"] = None
|
||||
|
||||
def _getitem_helper(self, arg: int) -> Union[list, NDArray]:
|
||||
|
@ -218,18 +218,18 @@ class VectorIndexMixin(BaseModel):
|
|||
Mimicking :func:`hdmf.common.table.VectorIndex.__getitem_helper`
|
||||
"""
|
||||
|
||||
start = 0 if arg == 0 else self.array[arg - 1]
|
||||
end = self.array[arg]
|
||||
start = 0 if arg == 0 else self.value[arg - 1]
|
||||
end = self.value[arg]
|
||||
return self.target.array[slice(start, end)]
|
||||
|
||||
def __getitem__(self, item: Union[int, slice]) -> Any:
|
||||
if self.target is None:
|
||||
return self.array[item]
|
||||
return self.value[item]
|
||||
elif type(self.target).__name__ == "VectorData":
|
||||
if isinstance(item, int):
|
||||
return self._getitem_helper(item)
|
||||
else:
|
||||
idx = range(*item.indices(len(self.array)))
|
||||
idx = range(*item.indices(len(self.value)))
|
||||
return [self._getitem_helper(i) for i in idx]
|
||||
else:
|
||||
raise NotImplementedError("DynamicTableRange not supported yet")
|
||||
|
@ -239,7 +239,7 @@ class VectorIndexMixin(BaseModel):
|
|||
# VectorIndex is the thing that knows how to do the slicing
|
||||
self._index[key] = value
|
||||
else:
|
||||
self.array[key] = value
|
||||
self.value[key] = value
|
||||
|
||||
|
||||
DYNAMIC_TABLE_IMPORTS = Imports(
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import pdb
|
||||
import shutil
|
||||
import os
|
||||
import traceback
|
||||
|
|
Loading…
Reference in a new issue