Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SeqInfo constructor breaks on numpy integers in seqlengths #147

Closed
LTLA opened this issue Mar 6, 2025 · 1 comment · Fixed by #149
Closed

SeqInfo constructor breaks on numpy integers in seqlengths #147

LTLA opened this issue Mar 6, 2025 · 1 comment · Fixed by #149

Comments

@LTLA
Copy link
Member

LTLA commented Mar 6, 2025

For example:

import genomicranges
genomicranges.SeqInfo(["A"], seqlengths=[100])
## SeqInfo(number_of_seqnames=1, seqnames=['A'], seqlengths=[100], is_circular=[None], genome=[None])
genomicranges.SeqInfo(["A"], seqlengths=[numpy.uint64(100)])
## Traceback (most recent call last):
##  File "<stdin>", line 1, in <module>
##  File "/Users/luna/Library/Python/3.11/lib/python/site-packages/genomicranges/SeqInfo.py", line 152, in __init__
##     _validate_seqlengths(self._seqlengths, num_seqs)
##  File "/Users/luna/Library/Python/3.11/lib/python/site-packages/genomicranges/SeqInfo.py", line 25, in _validate_seqlengths
##     raise ValueError("'seqlengths' should be a list of integers.")
## ValueError: 'seqlengths' should be a list of integers.

Don't use is_list_of_type() if NumPy types might be present, or cast them to int() beforehand, e.g., by putting them into a IntegerList().

@LTLA
Copy link
Member Author

LTLA commented Mar 7, 2025

breaks dolomite-ranges when there are no None values in the seqlengths or is_circular.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant