diff --git a/src/genomicranges/GenomicRangesList.py b/src/genomicranges/GenomicRangesList.py index ae5b0b7..e3b8828 100644 --- a/src/genomicranges/GenomicRangesList.py +++ b/src/genomicranges/GenomicRangesList.py @@ -426,7 +426,7 @@ def set_names( or as a reference to the (in-place-modified) original. """ if names is not None: - _validate_optional_attrs(None, names, len(self)) + _validate_optional_attrs(self.get_mcols(), names, len(self)) if not isinstance(names, ut.Names): names = ut.Names(names) diff --git a/tests/test_grl_initialize.py b/tests/test_grl_initialize.py index f3e552f..4215259 100644 --- a/tests/test_grl_initialize.py +++ b/tests/test_grl_initialize.py @@ -42,3 +42,13 @@ def test_create_grl_should_fail(): def test_empty_grl(): grl = GenomicRangesList.empty(n=100) assert isinstance(grl, GenomicRangesList) + + +def test_grl_set_names(): + grl = GenomicRangesList(ranges=[a, b], names=["a", "b"]) + + grl_replace_names = grl.set_names(["aa", "bb"]) + + assert grl_replace_names is not None + assert isinstance(grl_replace_names, GenomicRangesList) + assert list(grl.get_names()) == ["a", "b"]