Skip to content

Commit

Permalink
Fix tests (#170)
Browse files Browse the repository at this point in the history
* Remove unnecessary pytest options

* Update dependency imports

* Add test for get_available_atlases

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update tests/tests/test_unit/test_plugin/test_register.py

Co-authored-by: Will Graham <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Will Graham <[email protected]>
  • Loading branch information
3 people authored Jan 2, 2024
1 parent 6391f81 commit 7efddfc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
18 changes: 16 additions & 2 deletions brainreg/napari/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import napari
import numpy as np
from bg_atlasapi import BrainGlobeAtlas
from brainglobe_napari_io.cellfinder.reader_dir import load_registration
from brainglobe_segmentation.atlas.utils import get_available_atlases
from bg_atlasapi.list_atlases import descriptors, utils
from brainglobe_napari_io.workflows.wholebrain_cell_reader_dir import (
load_registration,
)
from fancylog import fancylog
from magicgui import magicgui
from napari._qt.qthreading import thread_worker
Expand All @@ -32,6 +34,18 @@
PRE_PROCESSING_ARGS = None


def get_available_atlases():
"""
Get the available brainglobe atlases
:return: Dict of available atlases (["name":version])
"""
available_atlases = utils.conf_from_url(
descriptors.remote_url_base.format("last_versions.conf")
)
available_atlases = dict(available_atlases["atlases"])
return available_atlases


def add_registered_image_layers(
viewer: napari.Viewer, *, registration_directory: pathlib.Path
) -> Tuple[napari.layers.Image, napari.layers.Labels]:
Expand Down
15 changes: 0 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,6 @@ include = ["brainreg*"]

[tool.pytest.ini_options]
addopts = "--cov=brainreg"
filterwarnings = [
"error",
# Emitted by scikit-image on import, see https://github.com/scikit-image/scikit-image/issues/6663
# This filter should be removed when scikit-image 0.20 is released
"ignore:`np.bool8` is a deprecated alias for `np.bool_`",
# Emitted by nptyping, see https://github.com/ramonhagenaars/nptyping/issues/102
# for upstream issue
"ignore:`np.object0` is a deprecated alias for ``np.object0`",
"ignore:`np.int0` is a deprecated alias for `np.intp`",
"ignore:`np.uint0` is a deprecated alias for `np.uintp`",
"ignore:`np.void0` is a deprecated alias for `np.void`",
"ignore:`np.bytes0` is a deprecated alias for `np.bytes_`",
"ignore:`np.str0` is a deprecated alias for `np.str_`",
]
markers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')"]

[tool.black]
line-length = 79
Expand Down
Empty file.
20 changes: 20 additions & 0 deletions tests/tests/test_unit/test_plugin/test_register.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from brainreg.napari.register import get_available_atlases

atlas_name = "allen_mouse_50um"


def test_get_available_atlases():
atlases = get_available_atlases()

# arbitrary selection of atlases
expected_atlases = [
"allen_mouse_10um",
"allen_mouse_25um",
"allen_mouse_50um",
"mpin_zfish_1um",
]

for a in expected_atlases:
assert (
a in atlases.keys()
), f"{a} is not in the list of expected atlases"

0 comments on commit 7efddfc

Please sign in to comment.