-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for loading files and fix an issue with default alleles
- Loading branch information
Showing
6 changed files
with
120 additions
and
55 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
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 |
---|---|---|
@@ -1,59 +1,21 @@ | ||
from pandas.tests.extension.conftest import * | ||
|
||
|
||
# Below fixtures are copied from pandas.conftest | ||
# They could be imported, but that would require having hypothesis as a dependency | ||
@pytest.fixture(params=[None, lambda x: x]) | ||
def sort_by_key(request): | ||
""" | ||
Simple fixture for testing keys in sorting methods. | ||
Tests None (no key) and the identity key. | ||
""" | ||
return request.param | ||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--runslow", action="store_true", default=False, help="run slow tests" | ||
) | ||
|
||
|
||
@pytest.fixture(params=["__eq__", "__ne__", "__le__", "__lt__", "__ge__", "__gt__"]) | ||
def all_compare_operators(request): | ||
""" | ||
Fixture for dunder names for common compare operations | ||
* >= | ||
* > | ||
* == | ||
* != | ||
* < | ||
* <= | ||
""" | ||
return request.param | ||
def pytest_configure(config): | ||
config.addinivalue_line("markers", "slow: mark test as slow to run") | ||
|
||
|
||
_all_numeric_reductions = [ | ||
"sum", | ||
"max", | ||
"min", | ||
"mean", | ||
"prod", | ||
"std", | ||
"var", | ||
"median", | ||
"kurt", | ||
"skew", | ||
] | ||
|
||
|
||
@pytest.fixture(params=_all_numeric_reductions) | ||
def all_numeric_reductions(request): | ||
""" | ||
Fixture for numeric reduction names. | ||
""" | ||
return request.param | ||
|
||
|
||
_all_boolean_reductions = ["all", "any"] | ||
|
||
|
||
@pytest.fixture(params=_all_boolean_reductions) | ||
def all_boolean_reductions(request): | ||
""" | ||
Fixture for boolean reduction names. | ||
""" | ||
return request.param | ||
def pytest_collection_modifyitems(config, items): | ||
if config.getoption("--runslow"): | ||
# --runslow given in cli: do not skip slow tests | ||
return | ||
skip_slow = pytest.mark.skip(reason="need --runslow option to run") | ||
for item in items: | ||
if "slow" in item.keywords: | ||
item.add_marker(skip_slow) |
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,59 @@ | ||
import pytest | ||
|
||
|
||
# Below fixtures are copied from pandas.conftest | ||
# They could be imported, but that would require having hypothesis as a dependency | ||
@pytest.fixture(params=[None, lambda x: x]) | ||
def sort_by_key(request): | ||
""" | ||
Simple fixture for testing keys in sorting methods. | ||
Tests None (no key) and the identity key. | ||
""" | ||
return request.param | ||
|
||
|
||
@pytest.fixture(params=["__eq__", "__ne__", "__le__", "__lt__", "__ge__", "__gt__"]) | ||
def all_compare_operators(request): | ||
""" | ||
Fixture for dunder names for common compare operations | ||
* >= | ||
* > | ||
* == | ||
* != | ||
* < | ||
* <= | ||
""" | ||
return request.param | ||
|
||
|
||
_all_numeric_reductions = [ | ||
"sum", | ||
"max", | ||
"min", | ||
"mean", | ||
"prod", | ||
"std", | ||
"var", | ||
"median", | ||
"kurt", | ||
"skew", | ||
] | ||
|
||
|
||
@pytest.fixture(params=_all_numeric_reductions) | ||
def all_numeric_reductions(request): | ||
""" | ||
Fixture for numeric reduction names. | ||
""" | ||
return request.param | ||
|
||
|
||
_all_boolean_reductions = ["all", "any"] | ||
|
||
|
||
@pytest.fixture(params=_all_boolean_reductions) | ||
def all_boolean_reductions(request): | ||
""" | ||
Fixture for boolean reduction names. | ||
""" | ||
return request.param |
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,21 @@ | ||
from pathlib import Path | ||
import pytest | ||
|
||
from pandas_genomics import io | ||
|
||
data_dir = Path(__file__).parent.parent / "data" | ||
|
||
|
||
@pytest.fixture | ||
def plink_small(): | ||
bed_file = data_dir / "plink" / "plink_test_small.bed" | ||
result = io.from_plink(bed_file) | ||
return result | ||
|
||
|
||
@pytest.mark.slow | ||
@pytest.fixture | ||
def plink_medium(): | ||
bed_file = data_dir / "plink" / "plink_test_medium.bed" | ||
result = io.from_plink(bed_file) | ||
return result |
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,14 @@ | ||
import pytest | ||
|
||
|
||
def test_loaded_small(plink_small): | ||
"""Validate the small dataset""" | ||
# TODO: Add more assertions | ||
assert plink_small.shape == (150, 3020) | ||
|
||
|
||
@pytest.mark.slow | ||
def test_loaded_medium(plink_medium): | ||
"""Validate the medium dataset""" | ||
# TODO: Add more assertions | ||
assert plink_medium.shape == (600, 45100) |