Skip to content

Commit

Permalink
Avoid line-continuation
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Dec 8, 2023
1 parent c8596fe commit 8df179e
Show file tree
Hide file tree
Showing 5 changed files with 344 additions and 326 deletions.
10 changes: 7 additions & 3 deletions src/AutoSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,10 @@ def __check_fps(self):
self.fps_value_label.setText(str(fps))

def __is_current_split_out_of_range(self):
return self.split_image_number < 0 \
return (
self.split_image_number < 0
or self.split_image_number > len(self.split_images_and_loop_number) - 1
)

def undo_split(self, navigate_image_only: bool = False):
"""Undo Split" and "Prev. Img." buttons connect to here."""
Expand Down Expand Up @@ -497,8 +499,10 @@ def reset(self):
# Functions for the hotkeys to return to the main thread from signals and start their corresponding functions
def start_auto_splitter(self):
# If the auto splitter is already running or the button is disabled, don't emit the signal to start it.
if self.is_running \
or (not self.start_auto_splitter_button.isEnabled() and not self.is_auto_controlled):
if (
self.is_running
or (not self.start_auto_splitter_button.isEnabled() and not self.is_auto_controlled)
):
return

start_label = self.start_image_status_value_label.text()
Expand Down
12 changes: 8 additions & 4 deletions src/capture_method/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,20 @@ async def get_camera_info(index: int, device_name: str):
# backend = video_capture.getBackendName() # STS_ASSERT
# video_capture.grab() # STS_ERROR
# except cv2.error as error:
# return CameraInfo(index, device_name, True, backend) \
# if error.code in (cv2.Error.STS_ERROR, cv2.Error.STS_ASSERT) \
# return (
# CameraInfo(index, device_name, True, backend)
# if error.code in (cv2.Error.STS_ERROR, cv2.Error.STS_ASSERT)
# else None
# )
# finally:
# video_capture.release()

resolution = get_input_device_resolution(index)
return CameraInfo(index, device_name, False, backend, resolution) \
if resolution is not None \
return (
CameraInfo(index, device_name, False, backend, resolution)
if resolution is not None
else None
)

return [
camera_info
Expand Down
12 changes: 8 additions & 4 deletions src/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ def compare_l2_norm(source: MatLike, capture: MatLike, mask: MatLike | None = No
error = cv2.norm(source, capture, cv2.NORM_L2, mask)

# The L2 Error is summed across all pixels, so this normalizes
max_error = sqrt(source.size) * MAXBYTE \
if not is_valid_image(mask)\
max_error = (
sqrt(source.size) * MAXBYTE
if not is_valid_image(mask)
else sqrt(cv2.countNonZero(mask) * MASK_SIZE_MULTIPLIER)
)

if not max_error:
return 0.0
Expand All @@ -69,9 +71,11 @@ def compare_template(source: MatLike, capture: MatLike, mask: MatLike | None = N

# matchTemplate returns the sum of square differences, this is the max
# that the value can be. Used for normalizing from 0 to 1.
max_error = source.size * MAXBYTE * MAXBYTE \
if not is_valid_image(mask) \
max_error = (
source.size * MAXBYTE * MAXBYTE
if not is_valid_image(mask)
else cv2.countNonZero(mask)
)

return 1 - (min_val / max_error)

Expand Down
Loading

0 comments on commit 8df179e

Please sign in to comment.