Do not check bounds since it is always valid when everything is fine. (#95)
This commit is contained in:
parent
3086b5c31d
commit
5ac9f9b144
@ -171,18 +171,12 @@ class Batch:
|
|||||||
b[k] = Batch()
|
b[k] = Batch()
|
||||||
elif hasattr(v, '__len__') and (not isinstance(
|
elif hasattr(v, '__len__') and (not isinstance(
|
||||||
v, (np.ndarray, torch.Tensor)) or v.ndim > 0):
|
v, (np.ndarray, torch.Tensor)) or v.ndim > 0):
|
||||||
if _valid_bounds(len(v), index):
|
if isinstance(index, (int, np.integer)) or \
|
||||||
if isinstance(index, (int, np.integer)) or \
|
(isinstance(index, np.ndarray) and
|
||||||
(isinstance(index, np.ndarray) and
|
index.ndim == 0) or not isinstance(v, list):
|
||||||
index.ndim == 0) or \
|
b[k] = v[index]
|
||||||
not isinstance(v, list):
|
|
||||||
b[k] = v[index]
|
|
||||||
else:
|
|
||||||
b[k] = [v[i] for i in index]
|
|
||||||
else:
|
else:
|
||||||
raise IndexError(
|
b[k] = [v[i] for i in index]
|
||||||
f"Index {index} out of bounds for {type(v)} of "
|
|
||||||
f"len {len(self)}.")
|
|
||||||
return b
|
return b
|
||||||
|
|
||||||
def __setitem__(self, index: Union[
|
def __setitem__(self, index: Union[
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user