Skip to content

Commit

Permalink
Merge pull request #1 from brainglobe/fetch-xml-test-data
Browse files Browse the repository at this point in the history
Add test fixtures for cell matching regression test
  • Loading branch information
matham authored Jun 3, 2024
2 parents 041b9da + f7d1900 commit 4e73c40
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
from pathlib import Path

import pooch
import pytest


@pytest.fixture
def data_path():
"""Directory storing all test data"""
return Path(__file__).parent.parent / "data"


@pytest.fixture
def test_data_registry():
"""
Create a test data registry for BrainGlobe.
Returns:
pooch.Pooch: The test data registry object.
"""
registry = pooch.create(
path=pooch.os_cache("brainglobe_test_data"),
base_url="https://gin.g-node.org/BrainGlobe/test-data/raw/master/",
registry={
"cellfinder/cells-z-1000-1050.xml": None,
"cellfinder/other-cells-z-1000-1050.xml": None,
},
)
return registry
37 changes: 37 additions & 0 deletions tests/tests/test_cells/test_matches.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,36 @@
match_cells,
match_points,
)
from brainglobe_utils.IO.cells import get_cells


@pytest.fixture
def cells_and_other_cells(test_data_registry):
"""
Provides real-life cell coordinates from a CFOS-labelled brain from
two different cellfinder versions (pre- and post cellfinder PR #398).
Intended to be used for regression testing our cell matching code.
Parameters
----------
test_data_registry : Pooch.pooch
The BrainGlobe test data registry.
Returns
-------
cell_data : List[Cell]
The loaded cell data.
"""
cell_data_path = test_data_registry.fetch(
"cellfinder/cells-z-1000-1050.xml"
)
other_cell_data_path = test_data_registry.fetch(
"cellfinder/other_cells-z-1000-1050.xml"
)
cell_data = get_cells(cell_data_path)
other_cell_data = get_cells(other_cell_data_path)
return cell_data, other_cell_data


def as_cell(x: List[float]):
Expand All @@ -19,6 +49,13 @@ def as_cell(x: List[float]):
return cells


@pytest.mark.xfail
def test_cell_matching_regression(cells_and_other_cells):
cells, other_cells = cells_and_other_cells
# TODO implement cell matching regression test here, then remove xfail
assert False


@pytest.mark.parametrize("use_scipy", [True, False])
@pytest.mark.parametrize("pre_match", [True, False])
def test_cell_matches_equal_size(pre_match, use_scipy):
Expand Down

0 comments on commit 4e73c40

Please sign in to comment.