From cee3397286d9738ace060c430af77b52c1f33c5f Mon Sep 17 00:00:00 2001 From: Jayaram Kancherla Date: Tue, 1 Oct 2024 11:04:01 -0700 Subject: [PATCH 1/2] fix issue when replacing names of a `GenomicRangesList` --- src/genomicranges/GenomicRangesList.py | 2 +- tests/test_grl_initialize.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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..ac3ec2f 100644 --- a/tests/test_grl_initialize.py +++ b/tests/test_grl_initialize.py @@ -42,3 +42,12 @@ 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"] \ No newline at end of file From e9d28d52854d0e82889d9fc139ddd00cde333a16 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 18:10:51 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_grl_initialize.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_grl_initialize.py b/tests/test_grl_initialize.py index ac3ec2f..4215259 100644 --- a/tests/test_grl_initialize.py +++ b/tests/test_grl_initialize.py @@ -43,11 +43,12 @@ 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 grl_replace_names is not None assert isinstance(grl_replace_names, GenomicRangesList) - assert list(grl.get_names()) == ["a", "b"] \ No newline at end of file + assert list(grl.get_names()) == ["a", "b"]