Skip to content

Commit e8e5521

Browse files
committed
[tag] allow setting position and extent with a single number
1 parent f7cf536 commit e8e5521

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

nixio/tag.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright © 2014, German Neuroinformatics Node (G-Node)
2+
# Copyright © 2014 - 2022, German Neuroinformatics Node (G-Node)
33
#
44
# All rights reserved.
55
#
@@ -260,6 +260,8 @@ def position(self):
260260

261261
@position.setter
262262
def position(self, pos):
263+
if pos is not None and not hasattr(pos, "__getitem__"):
264+
pos = [pos]
263265
if pos is None or len(pos) == 0:
264266
if self._h5group.has_data("position"):
265267
del self._h5group["position"]
@@ -281,6 +283,8 @@ def extent(self):
281283

282284
@extent.setter
283285
def extent(self, ext):
286+
if ext is not None and not hasattr(ext, "__getitem__"):
287+
ext = [ext]
284288
if ext is None or len(ext) == 0:
285289
if self._h5group.has_data("extent"):
286290
del self._h5group["extent"]
@@ -313,6 +317,8 @@ def tagged_data(self, refidx, stop_rule=SliceMode.Exclusive):
313317
"do not match ", extent)
314318

315319
slices = self._calc_data_slices(ref, self.position, self.extent, stop_rule)
320+
if not all(slices):
321+
return DataView(ref, slices)
316322
if not self._slices_in_data(ref, slices):
317323
raise OutOfBounds("References data slice out of the extent of the "
318324
"DataArray!")

0 commit comments

Comments
 (0)