Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
validate_atlases.py: updated validate_mesh_structure_pairs function, …
Browse files Browse the repository at this point in the history
…test_validation.py: updated tests
  • Loading branch information
viktorpm committed Feb 16, 2024
1 parent 5cc07cf commit 8c9b5a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 6 additions & 2 deletions bg_atlasgen/validate_atlases.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,16 @@ def validate_mesh_structure_pairs(atlas: BrainGlobeAtlas):
if id not in ids_from_mesh_files:
in_bg_not_mesh.append(id)

if len(in_mesh_not_bg) or len(in_bg_not_mesh):
if len(in_mesh_not_bg) != 0:
raise AssertionError(
f"Structures with ID {in_bg_not_mesh} are in the atlas, but don't have a corresponding mesh file; "
f"Structures with IDs {in_mesh_not_bg} have a mesh file, but are not accessible through the atlas."
)

if len(in_bg_not_mesh) != 0:
raise AssertionError(
f"Structures with IDs {in_bg_not_mesh} are in the atlas, but don't have a corresponding mesh file."
)


def validate_atlas(atlas_name, version, validation_functions):
"""Validates the latest version of a given atlas"""
Expand Down
12 changes: 9 additions & 3 deletions tests/test_unit/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ def test_validate_mesh_structure_pairs_no_obj(atlas):
False for "admba_3d_e11_5_mouse_16um" (it has all pairs): no error is
raised by the validation function --> this test function catches it
"""

with pytest.raises(
AssertionError,
match=r"Structures with ID \[.*?\] are in the atlas, but don't have a corresponding mesh file;",
#match=r"Structures with IDs \[.*?\] are in the atlas, but don't have a corresponding mesh file.",
match=r"\[.*?\]",
):
validate_mesh_structure_pairs(atlas)

Expand All @@ -102,8 +103,13 @@ def test_validate_mesh_structure_pairs_not_in_atlas(atlas):
Currently no atlas fails the validation function this way so the [] is always empty
--> this test function should always raise an error
"""

with pytest.raises(
AssertionError,
match=r"Structures with IDs \[.*?\] have a mesh file, but are not accessible through the atlas.",
#match=r"Structures with IDs \[.*?\] have a mesh file, but are not accessible through the atlas.",

# Only checks if there's anything in the []. If there isn't --> error
# It runs without an error with "allen_mouse_10um" as it fills the []
match=r"\[.*?\]",
):
validate_mesh_structure_pairs(atlas)

0 comments on commit 8c9b5a1

Please sign in to comment.