Skip to content

Commit

Permalink
[dataArray] fix linter complaint
Browse files Browse the repository at this point in the history
  • Loading branch information
jgrewe committed Jun 5, 2021
1 parent a803bad commit d3a63cf
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions nixio/data_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,25 @@ def append_range_dimension(self, ticks=None, label=None, unit=None):
rdim.ticks = ticks
return rdim

def append_range_dimension_using_self(self, index=[-1]):
def append_range_dimension_using_self(self, index=None):
"""
Convenience function to append a new RangeDimension to the list of
existing dimensions that uses the DataArray itself as provider for the ticks.
This is a replacement for
rdim = array.append_range_dimension()
rdim.link_data_array(self, index)
:param index: The slice of the DataArray that contains the tick
values. This must be a vector of the data. Defaults to [-1], i.e. the full first dimension.
values. This must be a vector of the data. Defaults to None, which will be replaced by [-1], i.e. the full first dimension.
:type: list of int
:returns: the newly created RangeDimension
:rtype: RangeDimension
"""
index = len(self.dimensions) + 1

rdim = RangeDimension.create_new(self, index, None)
dim_index = len(self.dimensions) + 1
rdim = RangeDimension.create_new(self, dim_index, None)
if index is None:
index = [-1]
rdim.link_data_array(self, index)
return rdim

Expand All @@ -168,7 +169,7 @@ def delete_dimensions(self):
dimgroup = self._h5group.open_group("dimensions")
ndims = len(dimgroup)
for idx in range(ndims):
del dimgroup[str(idx+1)]
del dimgroup[str(idx + 1)]
return True

def _dimension_count(self):
Expand All @@ -192,7 +193,7 @@ def iter_dimensions(self):
which returns the index starting from one and the dimensions.
"""
for idx, dim in enumerate(self.dimensions):
yield idx+1, dim
yield idx + 1, dim

@property
def dtype(self):
Expand Down Expand Up @@ -302,7 +303,7 @@ def get_slice(self, positions, extents=None, mode=DataSliceMode.Index):
"DataArray.get_slice"
)
if mode == DataSliceMode.Index:
slices = tuple(slice(p, p+e) for p, e in zip(positions, extents))
slices = tuple(slice(p, p + e) for p, e in zip(positions, extents))
return DataView(self, slices)
elif mode == DataSliceMode.Data:
return self._get_slice_bydim(positions, extents)
Expand All @@ -317,11 +318,11 @@ def _get_slice_bydim(self, positions, extents):
if dim.dimension_type in (DimensionType.Sample,
DimensionType.Range):
dpos.append(dim.index_of(pos))
dext.append(dim.index_of(pos+ext)-dpos[-1])
dext.append(dim.index_of(pos + ext) - dpos[-1])
elif dim.dimension_type == DimensionType.Set:
dpos.append(int(pos))
dext.append(int(ext))
slices = tuple(slice(p, p+e) for p, e in zip(dpos, dext))
slices = tuple(slice(p, p + e) for p, e in zip(dpos, dext))
return DataView(self, slices)

@property
Expand Down

0 comments on commit d3a63cf

Please sign in to comment.