Skip to content

Commit

Permalink
Merge branch 'main' into pytorch
Browse files Browse the repository at this point in the history
  • Loading branch information
matham authored Aug 30, 2024
2 parents c096339 + f1b7684 commit 58dce7e
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 14 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ jobs:
# Run all supported Python versions on linux
os: [ubuntu-latest]
python-version: ["3.10", "3.11", "3.12"]
# Include one windows and two macOS (intel based and arm based) runs
# Include one windows and one macOS (arm based) run
include:
- os: macos-13
python-version: "3.12"
- os: macos-latest
python-version: "3.12"
- os: windows-latest
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.7
rev: v0.5.6
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 24.4.2
rev: 24.8.0
hooks:
- id: black
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,8 @@ pip install cellfinder>=1.0.0
Be sure to specify a version greater than version `v1.0.0` - prior to this version the `cellfinder` package had a very different structure that is incompatible with BrainGlobe version 1 and the other tools in the BrainGlobe suite.
See [our blog posts](https://brainglobe.info/blog/) for more information on the release of BrainGlobe version 1.

## Contributing

If you have encountered a bug whilst using cellfinder, please [open an issue on GitHub](https://github.com/brainglobe/cellfinder/issues).

If you are interested in contributing to cellfinder (thank you!) - please head over to our [developer documentation](https://brainglobe.info/community/developers/index.html).
## Seeking help or contributing
We are always happy to help users of our tools, and welcome any contributions. If you would like to get in contact with us for any reason, please see the [contact page of our website](https://brainglobe.info/contact.html).

## Citation
If you find this package useful, and use it in your research, please cite the following paper:
Expand Down
4 changes: 2 additions & 2 deletions cellfinder/napari/curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _get_layer_names(
layer_names = [
layer.name
for layer in self.viewer.layers
if type(layer) == layer_type
if isinstance(layer, layer_type)
]

if layer_names:
Expand Down Expand Up @@ -329,7 +329,7 @@ def mark_point_as_type(self, point_type: str):

if len(self.viewer.layers.selection) == 1:
layer = list(self.viewer.layers.selection)[0]
if type(layer) == napari.layers.Points:
if isinstance(layer, napari.layers.Points):
if len(layer.data) > 0:
if point_type == "cell":
destination_layer = self.training_data_cell_layer
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ dependencies = [
"fancylog>=0.0.7",
"natsort",
"numba",
"numpy<2.0.0; sys_platform=='win32'",
"numpy",
"scikit-image",
"scikit-learn",
"keras>=3.0.0",
"torch>=2.1.0,!=2.4",
"keras>=3.5.0",
"torch>=2.1.0,!=2.4.0",
"tifffile",
"tqdm",
]
Expand Down
7 changes: 7 additions & 0 deletions tests/napari/test_curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def curation_widget(make_napari_viewer):
return widget


@pytest.mark.xfail(reason="See discussion in #443", raises=AssertionError)
def test_add_new_training_layers(curation_widget):
viewer = curation_widget.viewer
layers = viewer.layers
Expand All @@ -38,6 +39,7 @@ def test_add_new_training_layers(curation_widget):
assert layers[1].name == "Training data (non cells)"


@pytest.mark.xfail(reason="See discussion in #443", raises=AssertionError)
def test_cell_marking(curation_widget, tmp_path):
"""
Check that marking cells and non-cells works as expected.
Expand Down Expand Up @@ -130,13 +132,15 @@ def valid_curation_widget(make_napari_viewer) -> CurationWidget:
return curation_widget


@pytest.mark.xfail(reason="See discussion in #443", raises=AssertionError)
def test_check_image_data_for_extraction(valid_curation_widget):
"""
Check valid curation widget has extractable data.
"""
assert valid_curation_widget.check_image_data_for_extraction()


@pytest.mark.xfail(reason="See discussion in #443", raises=AssertionError)
def test_check_image_data_wrong_shape(valid_curation_widget):
"""
Check curation widget shows expected user message if images don't have
Expand All @@ -156,6 +160,7 @@ def test_check_image_data_wrong_shape(valid_curation_widget):
)


@pytest.mark.xfail(reason="See discussion in #443", raises=AssertionError)
def test_check_image_data_missing_signal(valid_curation_widget):
"""
Check curation widget shows expected user message if signal image is
Expand All @@ -170,12 +175,14 @@ def test_check_image_data_missing_signal(valid_curation_widget):
)


@pytest.mark.xfail(reason="See discussion in #443", raises=AssertionError)
def test_is_data_extractable(curation_widget, valid_curation_widget):
"""Check is_data_extractable works as expected."""
assert not curation_widget.is_data_extractable()
assert valid_curation_widget.is_data_extractable()


@pytest.mark.xfail(reason="See discussion in #443", raises=AssertionError)
def test_get_output_directory(valid_curation_widget):
"""Check get_output_directory returns expected value."""
with patch(
Expand Down
2 changes: 2 additions & 0 deletions tests/napari/test_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def test_detect_worker():
worker.work()


@pytest.mark.xfail(reason="See discussion in #443", raises=AssertionError)
@pytest.mark.parametrize(
argnames="analyse_local",
argvalues=[True, False], # increase test coverage by covering both cases
Expand All @@ -67,6 +68,7 @@ def test_run_detect_without_inputs():
assert show_info.called


@pytest.mark.xfail(reason="See discussion in #443", raises=AssertionError)
def test_reset_defaults(get_detect_widget):
"""Smoke test that restore defaults doesn't error."""
get_detect_widget.reset_button.clicked()
3 changes: 3 additions & 0 deletions tests/napari/test_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def get_training_widget(make_napari_viewer):
return widget


@pytest.mark.xfail(reason="See discussion in #443", raises=AssertionError)
def test_reset_to_defaults(get_training_widget):
"""
A simple test for the reset button.
Expand All @@ -45,6 +46,7 @@ def test_reset_to_defaults(get_training_widget):
assert get_training_widget.test_fraction.value == 0.10


@pytest.mark.xfail(reason="See discussion in #443", raises=AssertionError)
def test_run_with_no_yaml_files(get_training_widget):
"""
Checks whether expected info message will be shown to user if they don't
Expand All @@ -57,6 +59,7 @@ def test_run_with_no_yaml_files(get_training_widget):
)


@pytest.mark.xfail(reason="See discussion in #443", raises=AssertionError)
def test_run_with_virtual_yaml_files(get_training_widget):
"""
Checks that training is run with expected set of parameters.
Expand Down
2 changes: 2 additions & 0 deletions tests/napari/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import pytest
from brainglobe_utils.cells.cells import Cell

from cellfinder.napari.utils import (
Expand All @@ -10,6 +11,7 @@
)


@pytest.mark.xfail(reason="See discussion in #443", raises=AssertionError)
def test_add_classified_layers(make_napari_viewer):
"""Smoke test for add_classified_layers utility"""
cell_pos = [1, 2, 3]
Expand Down

0 comments on commit 58dce7e

Please sign in to comment.