Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 31, 2025
1 parent 692d240 commit 674201c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion tests/test_annotation_tilerendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def sub_tile_level_count(self: MockTileGenerator) -> int:


def test_unknown_geometry(
fill_store: Callable, # noqa: ARG001
fill_store: Callable,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test warning when unknown geometries cannot be rendered."""
Expand Down
10 changes: 5 additions & 5 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,9 @@ def test_sub_pixel_read_bad_read_func() -> None:
bounds = (0, 0, 8, 8)

def bad_read_func(
img: np.ndarray, # noqa: ARG001
bounds: IntBounds, # noqa: ARG001
*kwargs: dict, # noqa: ARG001
img: np.ndarray,
bounds: IntBounds,
*kwargs: dict,
) -> None:
"""Dummy function for a failing test."""
return
Expand Down Expand Up @@ -740,7 +740,7 @@ def test_sub_pixel_read_incorrect_read_func_return() -> None:
bounds = (0, 0, 8, 8)
image = np.ones((10, 10))

def read_func(*args: tuple, **kwargs: dict) -> np.ndarray: # noqa: ARG001
def read_func(*args: tuple, **kwargs: dict) -> np.ndarray:
"""Dummy read function for tests."""
return np.ones((5, 5))

Expand All @@ -759,7 +759,7 @@ def test_sub_pixel_read_empty_read_func_return() -> None:
bounds = (0, 0, 8, 8)
image = np.ones((10, 10))

def read_func(*args: tuple, **kwargs: dict) -> np.ndarray: # noqa: ARG001
def read_func(*args: tuple, **kwargs: dict) -> np.ndarray:
"""Dummy read function for tests."""
return np.ones((0, 0))

Expand Down
54 changes: 27 additions & 27 deletions tiatoolbox/visualization/bokeh_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ def __setattr__(

# Define UI callbacks
# region
def res_switch_cb(attr: str, old: int, new: int) -> None: # noqa: ARG001
def res_switch_cb(attr: str, old: int, new: int) -> None:
"""Callback to switch between resolutions."""
if new == 0:
UI["vstate"].res = 1
Expand All @@ -864,7 +864,7 @@ def res_switch_cb(attr: str, old: int, new: int) -> None: # noqa: ARG001
UI["vstate"].to_update.update(["overlay", "slide"])


def slide_toggle_cb(attr: str) -> None: # noqa: ARG001
def slide_toggle_cb(attr: str) -> None:
"""Callback to toggle the slide on/off."""
if UI["p"].renderers[0].alpha == 0:
UI["p"].renderers[0].alpha = UI["slide_alpha"].value
Expand All @@ -877,7 +877,7 @@ def node_select_cb(attr: str, old: int, new: int) -> None:
# Do something on node select if desired


def overlay_toggle_cb(attr: str) -> None: # noqa: ARG001
def overlay_toggle_cb(attr: str) -> None:
"""Callback to toggle the overlay on/off."""
for i in range(5, len(UI["p"].renderers)):
if UI["p"].renderers[i].alpha == 0:
Expand Down Expand Up @@ -935,14 +935,14 @@ def populate_slide_list(slide_folder: Path, search_txt: str | None = None) -> No
UI["slide_select"].options = file_list


def filter_input_cb(attr: str, old: str, new: str) -> None: # noqa: ARG001 # skipcq: PYL-W0613
def filter_input_cb(attr: str, old: str, new: str) -> None: # skipcq: PYL-W0613
"""Change predicate to be used to filter annotations."""
build_predicate()
UI["vstate"].update_state = 1
UI["vstate"].to_update.update(["overlay"])


def cprop_input_cb(attr: str, old: str, new: list[str]) -> None: # noqa: ARG001 # skipcq: PYL-W0613
def cprop_input_cb(attr: str, old: str, new: list[str]) -> None: # skipcq: PYL-W0613
"""Change property to color by."""
if len(new) == 0:
return
Expand All @@ -957,30 +957,30 @@ def cprop_input_cb(attr: str, old: str, new: list[str]) -> None: # noqa: ARG001
UI["vstate"].to_update.update(["overlay"])


def slide_alpha_cb(attr: str, old: float, new: float) -> None: # noqa: ARG001
def slide_alpha_cb(attr: str, old: float, new: float) -> None:
"""Callback to change the alpha of the slide."""
UI["p"].renderers[0].alpha = new


def overlay_alpha_cb(attr: str, old: float, new: float) -> None: # noqa: ARG001
def overlay_alpha_cb(attr: str, old: float, new: float) -> None:
"""Callback to change the alpha of all overlay layers."""
for i in range(5, len(UI["p"].renderers)):
UI["p"].renderers[i].alpha = new


def pt_size_cb(attr: str, old: float, new: float) -> None: # noqa: ARG001
def pt_size_cb(attr: str, old: float, new: float) -> None:
"""Callback to change the size of the points."""
UI["vstate"].graph_node.radius = 2 * new


def edge_size_cb(attr: str, old: float, new: float) -> None: # noqa: ARG001
def edge_size_cb(attr: str, old: float, new: float) -> None:
"""Callback to change the size of the edges."""
update_renderer("edge_thickness", new)
UI["vstate"].update_state = 1
UI["vstate"].to_update.update(["overlay"])


def opt_buttons_cb(attr: str, old: list[int], new: list[int]) -> None: # noqa: ARG001
def opt_buttons_cb(attr: str, old: list[int], new: list[int]) -> None:
"""Callback to handle options changes in the ui widget."""
old_thickness = UI["vstate"].thickness
if FILLED in new:
Expand Down Expand Up @@ -1008,22 +1008,22 @@ def opt_buttons_cb(attr: str, old: list[int], new: list[int]) -> None: # noqa:
UI["p"].xgrid.grid_line_alpha = 0


def cmap_select_cb(attr: str, old: str, new: str) -> None: # noqa: ARG001
def cmap_select_cb(attr: str, old: str, new: str) -> None:
"""Callback to change the color map."""
if not (UI["vstate"].is_categorical and new != "dict"):
update_renderer("mapper", new)
UI["vstate"].update_state = 1
UI["vstate"].to_update.update(["overlay"])


def blur_spinner_cb(attr: str, old: float, new: float) -> None: # noqa: ARG001
def blur_spinner_cb(attr: str, old: float, new: float) -> None:
"""Callback to change the blur radius."""
update_renderer("blur_radius", new)
UI["vstate"].update_state = 1
UI["vstate"].to_update.update(["overlay"])


def scale_spinner_cb(attr: str, old: float, new: float) -> None: # noqa: ARG001
def scale_spinner_cb(attr: str, old: float, new: float) -> None:
"""Callback to change the max scale.
This defines a scale above which small annotations are
Expand All @@ -1035,7 +1035,7 @@ def scale_spinner_cb(attr: str, old: float, new: float) -> None: # noqa: ARG001
UI["vstate"].to_update.update(["overlay"])


def slide_select_cb(attr: str, old: str, new: str) -> None: # noqa: ARG001
def slide_select_cb(attr: str, old: str, new: str) -> None:
"""Set up the newly chosen slide."""
if len(new) == 0:
return
Expand Down Expand Up @@ -1200,14 +1200,14 @@ def layer_drop_cb(attr: MenuItemClick) -> None:
change_tiles(resp)


def layer_select_cb(attr: ButtonClick) -> None: # noqa: ARG001
def layer_select_cb(attr: ButtonClick) -> None:
"""Callback to handle toggling specific annotation types on and off."""
build_predicate()
UI["vstate"].update_state = 1
UI["vstate"].to_update.update(["overlay"])


def fixed_layer_select_cb(obj: Button, attr: ButtonClick) -> None: # noqa: ARG001
def fixed_layer_select_cb(obj: Button, attr: ButtonClick) -> None:
"""Callback to handle toggling non-annotation layers on and off."""
key = UI["vstate"].layer_dict[obj.label]
if obj.label == "edges":
Expand All @@ -1231,8 +1231,8 @@ def fixed_layer_select_cb(obj: Button, attr: ButtonClick) -> None: # noqa: ARG0

def layer_slider_cb(
obj: Slider,
attr: str, # noqa: ARG001
old: float, # noqa: ARG001
attr: str,
old: float,
new: float,
) -> None:
"""Callback to handle changing the alpha of a layer."""
Expand All @@ -1251,8 +1251,8 @@ def layer_slider_cb(

def color_input_cb(
obj: ColorPicker,
attr: str, # noqa: ARG001
old: str, # noqa: ARG001
attr: str,
old: str,
new: str,
) -> None:
"""Callback to handle changing the color of an annotation type."""
Expand Down Expand Up @@ -1283,12 +1283,12 @@ def wrapped(attr: ButtonClick) -> None:
return wrapped


def model_drop_cb(attr: str, old: str, new: str) -> None: # noqa: ARG001
def model_drop_cb(attr: str, old: str, new: str) -> None:
"""Callback to handle model selection."""
UI["vstate"].current_model = new


def to_model_cb(attr: ButtonClick) -> None: # noqa: ARG001
def to_model_cb(attr: ButtonClick) -> None:
"""Callback to run currently selected model."""
if UI["vstate"].current_model == "hovernet":
segment_on_box()
Expand All @@ -1297,7 +1297,7 @@ def to_model_cb(attr: ButtonClick) -> None: # noqa: ARG001
logger.warning("unknown model")


def type_cmap_cb(attr: str, old: list[str], new: list[str]) -> None: # noqa: ARG001
def type_cmap_cb(attr: str, old: list[str], new: list[str]) -> None:
"""Callback to handle changing a type-specific color property."""
if len(new) == 0:
# Remove type-specific coloring
Expand Down Expand Up @@ -1362,7 +1362,7 @@ def type_cmap_cb(attr: str, old: list[str], new: list[str]) -> None: # noqa: AR
UI["vstate"].to_update.update(["overlay"])


def save_cb(attr: ButtonClick) -> None: # noqa: ARG001
def save_cb(attr: ButtonClick) -> None:
"""Callback to handle saving annotations."""
save_path = make_safe_name(
str(
Expand Down Expand Up @@ -2132,7 +2132,7 @@ def update() -> None:
UI["vstate"].update_state = DO_UPDATE


def control_tabs_cb(attr: str, old: int, new: int) -> None: # noqa: ARG001
def control_tabs_cb(attr: str, old: int, new: int) -> None:
"""Callback to handle selecting active window."""
if new == 1 and len(slide_wins.children) == 1:
# Make new window
Expand All @@ -2154,8 +2154,8 @@ def control_tabs_cb(attr: str, old: int, new: int) -> None: # noqa: ARG001


def control_tabs_remove_cb(
attr: str, # noqa: ARG001
old: list[int], # noqa: ARG001
attr: str,
old: list[int],
new: list[int],
) -> None:
"""Callback to handle removing a window."""
Expand Down

0 comments on commit 674201c

Please sign in to comment.