diff --git a/src/iranges/IRanges.py b/src/iranges/IRanges.py index 85a9958..eebd87e 100644 --- a/src/iranges/IRanges.py +++ b/src/iranges/IRanges.py @@ -95,6 +95,7 @@ def _sanitize_names(self, names): return None elif not isinstance(names, list): names = list(names) + return names def _validate_names(self): @@ -119,7 +120,7 @@ def _validate_mcols(self): if self._mcols.shape[0] != len(self._start): raise ValueError( - "Number of rows of 'mcols' should be equal to length of 'start'" + "Number of rows in 'mcols' should be equal to length of 'start'" ) def _sanitize_metadata(self, metadata): @@ -448,7 +449,7 @@ def __getitem__( start=self._start[idx], width=self._width[idx], names=ut.subset(self._names, idx) if self._names is not None else None, - mcols=self._mcols[list(idx), :], # doesn't support ranges yet. + mcols=self._mcols[list(idx), :], metadata=self._metadata, ) @@ -473,7 +474,7 @@ def __setitem__( idx, scalar = ut.normalize_subscript(args, len(self), self._names) self._start[idx] = value._start self._width[idx] = value._width - # self._mcols[list(idx),:] = value._mcols # doesn't support ranges yet. + self._mcols[list(idx), :] = value._mcols if value._names is not None: if self._names is None: diff --git a/tests/test_IRanges.py b/tests/test_IRanges.py index d20c908..c2fa96b 100644 --- a/tests/test_IRanges.py +++ b/tests/test_IRanges.py @@ -67,7 +67,7 @@ def test_IRanges_metadata(): with pytest.raises(ValueError) as ex: IRanges(starts, widths, mcols=BiocFrame({}, number_of_rows=3)) - assert str(ex.value).find("number of rows") >= 0 + assert str(ex.value).find("Number of rows") >= 0 assert x.get_metadata() == {} y = x.set_metadata({"A": 2})