From 7efddfc62a5a1e20e996168fb590e9b527e03b0f Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 2 Jan 2024 15:10:05 +0000 Subject: [PATCH] Fix tests (#170) * 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 <32364977+willGraham01@users.noreply.github.com> * [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 <32364977+willGraham01@users.noreply.github.com> --- brainreg/napari/register.py | 18 +++++++++++++++-- pyproject.toml | 15 -------------- tests/tests/test_unit/test_plugin/__init__.py | 0 .../test_unit/test_plugin/test_register.py | 20 +++++++++++++++++++ 4 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 tests/tests/test_unit/test_plugin/__init__.py create mode 100644 tests/tests/test_unit/test_plugin/test_register.py diff --git a/brainreg/napari/register.py b/brainreg/napari/register.py index 33545ae..3892efd 100644 --- a/brainreg/napari/register.py +++ b/brainreg/napari/register.py @@ -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 @@ -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]: diff --git a/pyproject.toml b/pyproject.toml index a925d6d..59956ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 diff --git a/tests/tests/test_unit/test_plugin/__init__.py b/tests/tests/test_unit/test_plugin/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/tests/test_unit/test_plugin/test_register.py b/tests/tests/test_unit/test_plugin/test_register.py new file mode 100644 index 0000000..886d9b9 --- /dev/null +++ b/tests/tests/test_unit/test_plugin/test_register.py @@ -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"