Skip to content

Commit

Permalink
Fix validation error when replacing names of a GenomicRangesList (#123
Browse files Browse the repository at this point in the history
)

Also add tests
  • Loading branch information
jkanche authored Oct 1, 2024
1 parent 5f6756e commit 50d1a61
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/genomicranges/GenomicRangesList.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_grl_initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit 50d1a61

Please sign in to comment.