From 36fec30d0fdc8a313842906f9384fef7422ecce0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 24 Nov 2024 15:21:55 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mqt/qao/karp/karp_number.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/mqt/qao/karp/karp_number.py b/src/mqt/qao/karp/karp_number.py index 631487e..268706b 100644 --- a/src/mqt/qao/karp/karp_number.py +++ b/src/mqt/qao/karp/karp_number.py @@ -9,7 +9,7 @@ from collections import defaultdict from functools import partial from pathlib import Path -from typing import TYPE_CHECKING, Any, Literal, Union +from typing import TYPE_CHECKING, Any, Literal import matplotlib.pyplot as plt import networkx as nx @@ -136,7 +136,8 @@ def sat( clauses = [[str(item[0]), str(item[1])] for item in input_data] filename = "" else: - raise ValueError("Invalid input_data type. Expected str or list[tuple[int, int]].") + msg = "Invalid input_data type. Expected str or list[tuple[int, int]]." + raise ValueError(msg) graph = KarpNumber._create_graph(clauses) @@ -304,7 +305,7 @@ def three_sat( @staticmethod def check_three_sat_solution( clauses: list[list[str]], solution: dict[str, float] - ) -> dict[str, Union[bool, list[list[str]], dict[str, str]]]: + ) -> dict[str, bool | list[list[str]] | dict[str, str]]: """Validates a solution for the 3-SAT problem by checking clause satisfaction.""" not_satisfied_clauses = [] @@ -740,7 +741,7 @@ def number_partition( @staticmethod def check_number_partition_solution( elements: list[int], set_variables: dict[str, float] - ) -> dict[str, int | int | bool | list[int]] | dict[Any, Any]: + ) -> dict[str, int | bool | list[int]] | dict[Any, Any]: """Validates a number partition solution by comparing subset sums.""" set_1 = [] set_2 = [] @@ -762,7 +763,7 @@ def check_number_partition_solution( set_2.append(elements[index]) missing_elements.remove(elements[index]) - result: dict[str, Union[int, bool, list[int]]] = { + result: dict[str, int | bool | list[int]] = { "Sum 1": sum_1, "Sum 2": sum_2, } @@ -784,7 +785,7 @@ def job_sequencing( b: float = 1, solve: bool = False, solver_method: Callable[..., Any] | None = None, - read_solution : Literal["print", "file"] | None = None, + read_solution: Literal["print", "file"] | None = None, solver_params: dict[str, Any] | None = None, ) -> Problem | list[list[int]]: """Initializes and optionally solves a job sequencing problem to minimize scheduling conflicts. Pattern check for files is not included.""" @@ -792,7 +793,7 @@ def job_sequencing( msg = "'solve' must be True if 'solver_method', 'read_solution', or 'solver_params' are provided." raise ValueError(msg) - if isinstance(input_data , str): + if isinstance(input_data, str): filename = input_data try: with Path(filename).open(encoding="utf-8") as file: