Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI updates #569

Merged
merged 3 commits into from
Jan 7, 2025
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
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ repos:
rev: 0.8.0
hooks:
- id: python-versions
- repo: https://github.com/sbrunner/jsonschema-validator
rev: 0.3.2
hooks:
- id: jsonschema-validator
files: ^\.github/publish\.yaml$
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2019-2024, Stéphane Brunner
Copyright (c) 2019-2025, Stéphane Brunner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
23 changes: 11 additions & 12 deletions deskew/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,19 @@ def determine_skew_dev(
image: ImageType,
sigma: float = 3.0,
num_peaks: int = 20,
min_angle: Optional[float] = None, # -np.pi / 2,
max_angle: Optional[float] = None, # np.pi / 2,
min_angle: float | None = None, # -np.pi / 2,
max_angle: float | None = None, # np.pi / 2,
min_deviation: float = np.pi / 180,
angle_pm_90: bool = False,
) -> tuple[
Optional[np.float64],
np.float64 | None,
tuple[
tuple[ImageTypeUint64, list[list[np.float64]], ImageTypeFloat64],
tuple[list[Any], list[np.float64], list[np.float64]],
tuple[dict[np.float64, int], dict[np.float64, int]],
],
]:
"""Calculate skew angle."""

num_angles = round(np.pi / min_deviation)
imagergb = rgba2rgb(image) if len(image.shape) == 3 and image.shape[2] == 4 else image # type: ignore[no-untyped-call]
img = rgb2gray(imagergb) if len(imagergb.shape) == 3 else imagergb
Expand Down Expand Up @@ -106,10 +105,10 @@ def determine_skew_debug_images(
sigma: float = 3.0,
num_peaks: int = 20,
angle_pm_90: bool = False,
min_angle: Optional[float] = None,
max_angle: Optional[float] = None,
min_angle: float | None = None,
max_angle: float | None = None,
min_deviation: float = 1.0,
) -> tuple[Optional[np.float64], list[tuple[str, ImageType]]]:
) -> tuple[np.float64 | None, list[tuple[str, ImageType]]]:
"""Calculate skew angle, and return images useful for debugging."""
import cv2 # pylint: disable=import-outside-toplevel
import matplotlib.pyplot as plt # pylint: disable=import-outside-toplevel
Expand Down Expand Up @@ -222,7 +221,7 @@ def determine_skew_debug_images(
axe.set_axis_off()
axe.set_title("Detected lines")

for _, line_angle, dist in zip(*hough_line_peaks_data):
for _, line_angle, dist in zip(*hough_line_peaks_data, strict=False):
(coord0x, coord0y) = dist * np.array([np.cos(line_angle), np.sin(line_angle)])
angle2 = (
(line_angle % np.pi - np.pi / 2)
Expand Down Expand Up @@ -306,12 +305,12 @@ def determine_skew(
image: ImageType,
sigma: float = 3.0,
num_peaks: int = 20,
num_angles: Optional[int] = None,
num_angles: int | None = None,
angle_pm_90: bool = False,
min_angle: Optional[float] = None,
max_angle: Optional[float] = None,
min_angle: float | None = None,
max_angle: float | None = None,
min_deviation: float = 1.0,
) -> Optional[np.float64]:
) -> np.float64 | None:
"""
Calculate skew angle.

Expand Down
Loading