-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use an appropriate NumPy dtype based on the number of unique sequences (
#118) Add tests to check the `dtype` assignment.
- Loading branch information
Showing
2 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import pytest | ||
from genomicranges import GenomicRanges | ||
from iranges import IRanges | ||
from biocframe import BiocFrame | ||
from random import random | ||
import pandas as pd | ||
import numpy as np | ||
|
||
__author__ = "jkanche" | ||
__copyright__ = "jkanche" | ||
__license__ = "MIT" | ||
|
||
|
||
def test_create_gr(): | ||
gr = GenomicRanges( | ||
seqnames=["chr1"] * 10, | ||
ranges=IRanges(start=range(100, 110), width=range(110, 120)), | ||
) | ||
|
||
assert gr is not None | ||
assert gr._seqnames.dtype == np.int8 | ||
|
||
gr16 = GenomicRanges( | ||
seqnames=[f"chr{i}" for i in range(500)], | ||
ranges=IRanges(start=range(0, 500), width=range(10, 510)), | ||
) | ||
|
||
assert gr16 is not None | ||
assert gr16._seqnames.dtype == np.int16 | ||
|
||
gr32 = GenomicRanges( | ||
seqnames=[f"chr{i}" for i in range(2**16 + 1)], | ||
ranges=IRanges(start=range(0, 2**16 + 1), width=range(10, 2**16 + 11)), | ||
) | ||
|
||
assert gr32 is not None | ||
assert gr32._seqnames.dtype == np.int32 |