Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 26 additions & 40 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-docstring-first
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: ^.napari-hub/*
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
hooks:
- id: pyupgrade
args: [--py38-plus, --keep-runtime-typing]
- repo: https://github.com/myint/autoflake
rev: v2.3.1
hooks:
- id: autoflake
args: ["--in-place", "--remove-all-unused-imports"]
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: [flake8-typing-imports>=1.9.0]
- repo: https://github.com/tlambert03/napari-plugin-checks
rev: v0.3.0
hooks:
- id: napari-plugin-checks
# https://mypy.readthedocs.io/en/stable/introduction.html
# you may wish to add this as well!
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.910-1
# hooks:
# - id: mypy
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.2
hooks:
- id: ruff-format
exclude: examples
- id: ruff

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
# .py files are skipped cause already checked by other hooks
hooks:
- id: check-yaml
- id: check-toml
- id: check-merge-conflict
exclude: .*\.py
- id: end-of-file-fixer
exclude: .*\.py
- id: trailing-whitespace
# trailing whitespace has meaning in markdown https://www.markdownguide.org/hacks/#indent-tab
exclude: .*\.py|.*\.md
- id: mixed-line-ending
exclude: .*\.py
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.33.2
hooks:
- id: check-github-workflows
81 changes: 77 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,82 @@ build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
write_to = "src/PartSeg_smfish/_version.py"

[tool.black]
[tool.ruff]
line-length = 79
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".mypy_cache",
".pants.d",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
"*vendored*",
"*_vendor*",
]

[tool.isort]
profile = "black"
line_length = 79
fix = true

[tool.ruff.format]
quote-style = "double"

[tool.ruff.lint]
select = [
"E", "F", "W", #flake8
"UP", # pyupgrade
"I", # isort
"YTT", #flake8-2020
"TC", # flake8-type-checing
"BLE", # flake8-blind-exception
"B", # flake8-bugbear
"A", # flake8-builtins
"C4", # flake8-comprehensions
"ISC", # flake8-implicit-str-concat
"G", # flake8-logging-format
"PIE", # flake8-pie
"COM", # flake8-commas
"SIM", # flake8-simplify
"INP", # flake8-no-pep420
"PYI", # flake8-pyi
"Q", # flake8-quotes
"RSE", # flake8-raise
"RET", # flake8-return
"TID", # flake8-tidy-imports # replace absolutify import
"TRY", # tryceratops
"ICN", # flake8-import-conventions
"RUF", # ruff specyfic rules
"NPY201", # checks compatibility with numpy version 2.0
"ASYNC", # flake8-async
"EXE", # flake8-executable
"FA", # flake8-future-annotations
"LOG", # flake8-logging
"SLOT", # flake8-slots
"PT", # flake8-pytest-style
"T20", # flake8-print
]
ignore = [
"COM812", # conflict with formatter
]

[tool.ruff.lint.pyupgrade]
keep-runtime-typing = true


[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"
inline-quotes = "double"
multiline-quotes = "double"

[tool.ruff.lint.isort]
known-first-party=['PartSeg_smfish']
combine-as-imports = true
3 changes: 1 addition & 2 deletions src/PartSeg_smfish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@


def register():
from PartSegCore.register import RegisterEnum
from PartSegCore.register import register as register_fun
from PartSegCore.register import RegisterEnum, register as register_fun

from . import measurement, segmentation

Expand Down
4 changes: 2 additions & 2 deletions src/PartSeg_smfish/_tests/test_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)


@pytest.mark.parametrize("mask", (True, False))
@pytest.mark.parametrize("mask", [True, False])
def test_gauss_estimate(mask):
param = GaussBackgroundEstimateParameters(
background_estimate_radius=5,
Expand All @@ -22,7 +22,7 @@ def test_gauss_estimate(mask):
GaussBackgroundEstimate.spot_estimate(data, mask, (10, 10), param)


@pytest.mark.parametrize("mask", (True, False))
@pytest.mark.parametrize("mask", [True, False])
def test_laplacian_estimate(mask):
param = LaplacianBackgroundEstimateParameters(
laplacian_radius=1.3,
Expand Down
19 changes: 16 additions & 3 deletions src/PartSeg_smfish/copy_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, napari_viewer: Viewer):
self.setLayout(layout)

self.viewer.layers.selection.events.active.connect(
self.activate_widget
self.activate_widget,
)
self.copy_btn.clicked.connect(self.copy_action)
self.check_all_btn.clicked.connect(self._check_all)
Expand Down Expand Up @@ -116,8 +116,21 @@ def copy_action(self):
checked = {layer.selected_label}
z_position = self.viewer.dims.current_step[layer.dtype.ndim - 3]
for component_num in checked:
mask = layer.data[leading_zeros + (z_position,)] == component_num
mask = (
layer.data[
(
*leading_zeros,
z_position,
)
]
== component_num
)
start = max(0, self.lower.value())
end = min(layer.data.shape[1] - 1, self.upper.value()) + 1
for i in range(start, end):
layer.data[leading_zeros + (i,)][mask] = component_num
layer.data[
(
*leading_zeros,
i,
)
][mask] = component_num
Loading