From 3883120909eace7c14312b9b9e54af53b31e93bc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 17:35:52 +0000 Subject: [PATCH 1/9] =?UTF-8?q?=E2=AC=86=EF=B8=8F=F0=9F=AA=9D=20update=20p?= =?UTF-8?q?re-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/srstevenson/nb-clean: 3.2.0 → 3.3.0](https://github.com/srstevenson/nb-clean/compare/3.2.0...3.3.0) - [github.com/astral-sh/ruff-pre-commit: v0.4.8 → v0.4.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.8...v0.4.9) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bbbc2ae..0af04ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,7 @@ repos: # Clean jupyter notebooks - repo: https://github.com/srstevenson/nb-clean - rev: 3.2.0 + rev: 3.3.0 hooks: - id: nb-clean args: @@ -58,7 +58,7 @@ repos: # Python linting using ruff - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.8 + rev: v0.4.9 hooks: - id: ruff args: ["--fix", "--show-fixes"] From 83891d075b6c0f63fb404d342f146044593448cb Mon Sep 17 00:00:00 2001 From: DeborahVolpe Date: Tue, 18 Jun 2024 19:06:30 +0200 Subject: [PATCH 2/9] Update code --- src/mqt/qao/constraints.py | 72 +++++++++++++++++++------------------- src/mqt/qao/problem.py | 10 +++--- src/mqt/qao/solvers.py | 6 ++-- tests/test_evaluation.py | 28 +++++++-------- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/mqt/qao/constraints.py b/src/mqt/qao/constraints.py index 54417e8..2233349 100644 --- a/src/mqt/qao/constraints.py +++ b/src/mqt/qao/constraints.py @@ -240,13 +240,13 @@ def _not_constraint_check(self, constraint: str, variables: Variables, solution: expr1_to_sub = bool(not str(expr1).replace(".", "").isnumeric()) expr2_to_sub = bool(not str(expr2).replace(".", "").isnumeric()) if expr2_to_sub or expr1_to_sub: - for var in solution: + for var, values in solution.items(): if var in variables.variables_dict: - if isinstance(solution[var], float): + if isinstance(values, float): expr1, expr2 = self._constraint_check_sub_single_var( - expr1_to_sub, expr2_to_sub, expr1, expr2, solution[var], variables.variables_dict[var] + expr1_to_sub, expr2_to_sub, expr1, expr2, values, variables.variables_dict[var] ) - elif isinstance(solution[var], list): + elif isinstance(values, list): expr1, expr2 = self._constraint_check_sub_list_var( solution, variables, @@ -380,9 +380,9 @@ def _and_constraint_check(self, constraint: str, variables: Variables, solution: expr2_to_sub = bool(not str(expr2).replace(".", "").isnumeric()) expr3_to_sub = bool(not str(expr3).replace(".", "").isnumeric()) if expr2_to_sub or expr1_to_sub or expr3_to_sub: - for var in solution: + for var, value in solution.items(): if var in variables.variables_dict: - if isinstance(solution[var], float): + if isinstance(value, float): expr1, expr2, expr3 = self._constraint_check_three_sub_single_var( expr1_to_sub, expr2_to_sub, @@ -390,10 +390,10 @@ def _and_constraint_check(self, constraint: str, variables: Variables, solution: expr1, expr2, expr3, - solution[var], + value, variables.variables_dict[var], ) - elif isinstance(solution[var], list): + elif isinstance(value, list): expr1, expr2, expr3 = self._constraint_check_three_sub_list_var( solution, variables, expr1, expr2, expr3, var, expr1_to_sub, expr2_to_sub, expr3_to_sub ) @@ -535,9 +535,9 @@ def _or_constraint_check(self, constraint: str, variables: Variables, solution: expr2_to_sub = bool(not str(expr2).replace(".", "").isnumeric()) expr3_to_sub = bool(not str(expr3).replace(".", "").isnumeric()) if expr2_to_sub or expr1_to_sub or expr3_to_sub: - for var in solution: + for var, value in solution.items(): if var in variables.variables_dict: - if isinstance(solution[var], float): + if isinstance(value, float): expr1, expr2, expr3 = self._constraint_check_three_sub_single_var( expr1_to_sub, expr2_to_sub, @@ -545,10 +545,10 @@ def _or_constraint_check(self, constraint: str, variables: Variables, solution: expr1, expr2, expr3, - solution[var], + value, variables.variables_dict[var], ) - elif isinstance(solution[var], list): + elif isinstance(value, list): expr1, expr2, expr3 = self._constraint_check_three_sub_list_var( solution, variables, expr1, expr2, expr3, var, expr1_to_sub, expr2_to_sub, expr3_to_sub ) @@ -765,9 +765,9 @@ def _xor_constraint_check(self, constraint: str, variables: Variables, solution: expr2_to_sub = bool(not str(expr2).replace(".", "").isnumeric()) expr3_to_sub = bool(not str(expr3).replace(".", "").isnumeric()) if expr2_to_sub or expr1_to_sub or expr3_to_sub: - for var in solution: + for var, value in solution.items(): if var in variables.variables_dict: - if isinstance(solution[var], float): + if isinstance(value, float): expr1, expr2, expr3 = self._constraint_check_three_sub_single_var( expr1_to_sub, expr2_to_sub, @@ -775,10 +775,10 @@ def _xor_constraint_check(self, constraint: str, variables: Variables, solution: expr1, expr2, expr3, - solution[var], + value, variables.variables_dict[var], ) - elif isinstance(solution[var], list): + elif isinstance(value, list): expr1, expr2, expr3 = self._constraint_check_three_sub_list_var( solution, variables, expr1, expr2, expr3, var, expr1_to_sub, expr2_to_sub, expr3_to_sub ) @@ -1008,13 +1008,13 @@ def _greq_constraint_check(self, constraint: str, variables: Variables, solution expr1_to_sub = bool(not str(expr1).replace(".", "").isnumeric()) expr2_to_sub = bool(not str(expr2).replace(".", "").isnumeric()) if expr2_to_sub or expr1_to_sub: - for var in solution: + for var, value in solution.items(): if var in variables.variables_dict: - if isinstance(solution[var], float): + if isinstance(value, float): expr1, expr2 = self._constraint_check_sub_single_var( - expr1_to_sub, expr2_to_sub, expr1, expr2, solution[var], variables.variables_dict[var] + expr1_to_sub, expr2_to_sub, expr1, expr2, value, variables.variables_dict[var] ) - elif isinstance(solution[var], list): + elif isinstance(value, list): expr1, expr2 = self._constraint_check_sub_list_var( solution, variables, expr1, expr2, var, expr1_to_sub, expr2_to_sub ) @@ -1175,13 +1175,13 @@ def _lteq_constraint_check(self, constraint: str, variables: Variables, solution expr1_to_sub = bool(not str(expr1).replace(".", "").isnumeric()) expr2_to_sub = bool(not str(expr2).replace(".", "").isnumeric()) if expr2_to_sub or expr1_to_sub: - for var in solution: + for var, value in solution.items(): if var in variables.variables_dict: - if isinstance(solution[var], float): + if isinstance(value, float): expr1, expr2 = self._constraint_check_sub_single_var( - expr1_to_sub, expr2_to_sub, expr1, expr2, solution[var], variables.variables_dict[var] + expr1_to_sub, expr2_to_sub, expr1, expr2, value, variables.variables_dict[var] ) - elif isinstance(solution[var], list): + elif isinstance(value, list): expr1, expr2 = self._constraint_check_sub_list_var( solution, variables, expr1, expr2, var, expr1_to_sub, expr2_to_sub ) @@ -1352,13 +1352,13 @@ def _grt_constraint_check(self, constraint: str, variables: Variables, solution: expr1_to_sub = bool(not str(expr1).replace(".", "").isnumeric()) expr2_to_sub = bool(not str(expr2).replace(".", "").isnumeric()) if expr2_to_sub or expr1_to_sub: - for var in solution: + for var, value in solution.items(): if var in variables.variables_dict: - if isinstance(solution[var], float): + if isinstance(value, float): expr1, expr2 = self._constraint_check_sub_single_var( - expr1_to_sub, expr2_to_sub, expr1, expr2, solution[var], variables.variables_dict[var] + expr1_to_sub, expr2_to_sub, expr1, expr2, value, variables.variables_dict[var] ) - elif isinstance(solution[var], list): + elif isinstance(value, list): expr1, expr2 = self._constraint_check_sub_list_var( solution, variables, expr1, expr2, var, expr1_to_sub, expr2_to_sub ) @@ -1532,13 +1532,13 @@ def _lt_constraint_check(self, constraint: str, variables: Variables, solution: expr1_to_sub = bool(not str(expr1).replace(".", "").isnumeric()) expr2_to_sub = bool(not str(expr2).replace(".", "").isnumeric()) if expr2_to_sub or expr1_to_sub: - for var in solution: + for var, value in solution.items(): if var in variables.variables_dict: - if isinstance(solution[var], float): + if isinstance(value, float): expr1, expr2 = self._constraint_check_sub_single_var( - expr1_to_sub, expr2_to_sub, expr1, expr2, solution[var], variables.variables_dict[var] + expr1_to_sub, expr2_to_sub, expr1, expr2, value, variables.variables_dict[var] ) - elif isinstance(solution[var], list): + elif isinstance(value, list): expr1, expr2 = self._constraint_check_sub_list_var( solution, variables, expr1, expr2, var, expr1_to_sub, expr2_to_sub ) @@ -1635,13 +1635,13 @@ def _eq_constraint_check(self, constraint: str, variables: Variables, solution: expr1_to_sub = bool(not str(expr1).replace(".", "").isnumeric()) expr2_to_sub = bool(not str(expr2).replace(".", "").isnumeric()) if expr2_to_sub or expr1_to_sub: - for var in solution: + for var, value in solution.items(): if var in variables.variables_dict: - if isinstance(solution[var], float): + if isinstance(value, float): expr1, expr2 = self._constraint_check_sub_single_var( - expr1_to_sub, expr2_to_sub, expr1, expr2, solution[var], variables.variables_dict[var] + expr1_to_sub, expr2_to_sub, expr1, expr2, value, variables.variables_dict[var] ) - elif isinstance(solution[var], list): + elif isinstance(value, list): expr1, expr2 = self._constraint_check_sub_list_var( solution, variables, expr1, expr2, var, expr1_to_sub, expr2_to_sub ) diff --git a/src/mqt/qao/problem.py b/src/mqt/qao/problem.py index 33f77d7..4d0f8a5 100644 --- a/src/mqt/qao/problem.py +++ b/src/mqt/qao/problem.py @@ -326,9 +326,9 @@ def _moc(cost_function: PUBO, constraint_function: PUBO) -> float: val = 0.0 first = True - for key in p_sum: + for key, value in p_sum.items(): if key in p_sum_constrained and p_sum_constrained[key] != 0: - v = p_sum[key] / p_sum_constrained[key] + v = value / p_sum_constrained[key] if v != 0 and first: val = v first = False @@ -394,9 +394,9 @@ def upper_lower_bound_posiform_and_negaform_method(cost_function: PUBO) -> float n_sum[elem] += cost_function[key] / len(key) lowerbound = 0.0 upperbound = 0.0 - for key in p_sum: - if p_sum[key] < 0: - lowerbound += p_sum[key] + for key, value in p_sum.items(): + if value < 0: + lowerbound += value if n_sum[key] > 0: upperbound += n_sum[key] return upperbound - lowerbound diff --git a/src/mqt/qao/solvers.py b/src/mqt/qao/solvers.py index c9eddca..3d91612 100644 --- a/src/mqt/qao/solvers.py +++ b/src/mqt/qao/solvers.py @@ -1259,9 +1259,9 @@ def wring_json_reports( elems_v = {} coeff_m = sum(coeff) / len(coeff) coeff_v = np.var(coeff) - for key in elems: - elems_m[key] = sum(elems[key]) / len(elems[key]) - elems_v[key] = np.var(elems[key]) + for key, value in elems.items(): + elems_m[key] = sum(value) / len(value) + elems_v[key] = np.var(value) data["qubo contributions"] = num_elm data["qubo contributions average"] = elems_m data["qubo contributions variance"] = elems_v diff --git a/tests/test_evaluation.py b/tests/test_evaluation.py index ca42fe5..b69bd34 100644 --- a/tests/test_evaluation.py +++ b/tests/test_evaluation.py @@ -339,8 +339,8 @@ def test_cost_function() -> None: for key in qubo: qubo_re[tuple(sorted(key))] = qubo[key] reference_qubo_dict_re = {} - for key in reference_qubo_dict: - reference_qubo_dict_re[tuple(sorted(key))] = reference_qubo_dict[key] + for key, value in reference_qubo_dict.items(): + reference_qubo_dict_re[tuple(sorted(key))] = value assert dict(sorted(qubo_re.items())) == dict(sorted(reference_qubo_dict_re.items())) @@ -392,8 +392,8 @@ def test_cost_function_matrix() -> None: for key in qubo: qubo_re[tuple(sorted(key))] = qubo[key] reference_qubo_dict_re = {} - for key in reference_qubo_dict: - reference_qubo_dict_re[tuple(sorted(key))] = reference_qubo_dict[key] + for key, value in reference_qubo_dict.items(): + reference_qubo_dict_re[tuple(sorted(key))] = value assert dict(sorted(qubo_re.items())) == dict(sorted(reference_qubo_dict_re.items())) @@ -449,13 +449,13 @@ def test_constraint(expression: str, var_precision: bool) -> None: for key in qubo_second: qubo_second_re[tuple(sorted(key))] = qubo_second[key] dictionary_constraints_qubo_re = {} - for key in dictionary_constraints_qubo: - dictionary_constraints_qubo_re[tuple(sorted(key))] = dictionary_constraints_qubo[key] + for key, value in dictionary_constraints_qubo.items(): + dictionary_constraints_qubo_re[tuple(sorted(key))] = value if expression == "~a = b": dictionary_constraints_qubo_2 = {("b0",): -1.0, ("b1",): -1.0, ("b0", "b1"): 2.0, (): 1.0} dictionary_constraints_qubo_2_re = {} - for key in dictionary_constraints_qubo_2: - dictionary_constraints_qubo_2_re[tuple(sorted(key))] = dictionary_constraints_qubo_2[key] + for key, value in dictionary_constraints_qubo_2.items(): + dictionary_constraints_qubo_2_re[tuple(sorted(key))] = value assert dict(sorted(qubo_second_re.items())) == dict(sorted(dictionary_constraints_qubo_2_re.items())) assert dict(sorted(qubo_first_re.items())) == dict(sorted(dictionary_constraints_qubo_re.items())) elif expression == "a & b = c": @@ -855,13 +855,13 @@ def test_constraint_no_sub(expression: str) -> None: for key in qubo_second: qubo_second_re[tuple(sorted(key))] = qubo_second[key] dictionary_constraints_qubo_re = {} - for key in dictionary_constraints_qubo: - dictionary_constraints_qubo_re[tuple(sorted(key))] = dictionary_constraints_qubo[key] + for key, value in dictionary_constraints_qubo.items(): + dictionary_constraints_qubo_re[tuple(sorted(key))] = value if expression == "~b0 = b1": dictionary_constraints_qubo_2 = {("b0",): -1, ("b1",): -1, ("b0", "b1"): 2, (): 1} dictionary_constraints_qubo_2_re = {} - for key in dictionary_constraints_qubo_2: - dictionary_constraints_qubo_2_re[tuple(sorted(key))] = dictionary_constraints_qubo_2[key] + for key, value in dictionary_constraints_qubo_2.items(): + dictionary_constraints_qubo_2_re[tuple(sorted(key))] = value assert dict(sorted(qubo_second_re.items())) == dict(sorted(dictionary_constraints_qubo_2_re.items())) assert dict(sorted(qubo_first_re.items())) == dict(sorted(dictionary_constraints_qubo_re.items())) @@ -945,8 +945,8 @@ def test_problem(lambda_strategy: str) -> None: for key in qubo: qubo_re[tuple(sorted(key))] = qubo[key] reference_qubo_dict_re = {} - for key in reference_qubo_dict: - reference_qubo_dict_re[tuple(sorted(key))] = reference_qubo_dict[key] + for key, value in reference_qubo_dict.items(): + reference_qubo_dict_re[tuple(sorted(key))] = value if lambda_strategy in {"upper_bound_only_positive", "upper lower bound naive"}: assert lambdas == [52.25 * 1.1] * 2 assert dict(sorted(qubo_re.items())) == dict(sorted(reference_qubo_dict_re.items())) From 4db8a1fb4c962b049aa8807425ffcbf7f74a5144 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:42:49 +0000 Subject: [PATCH 3/9] =?UTF-8?q?=E2=AC=86=EF=B8=8F=F0=9F=AA=9D=20update=20p?= =?UTF-8?q?re-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.1 → v0.6.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.1...v0.6.2) - [github.com/pre-commit/mirrors-mypy: v1.11.1 → v1.11.2](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.1...v1.11.2) - [github.com/crate-ci/typos: v1.23.6 → v1.24.1](https://github.com/crate-ci/typos/compare/v1.23.6...v1.24.1) - [github.com/scientific-python/cookie: 2024.04.23 → 2024.08.19](https://github.com/scientific-python/cookie/compare/2024.04.23...2024.08.19) - [github.com/python-jsonschema/check-jsonschema: 0.29.1 → 0.29.2](https://github.com/python-jsonschema/check-jsonschema/compare/0.29.1...0.29.2) - [github.com/henryiii/validate-pyproject-schema-store: 2024.08.08 → 2024.08.19](https://github.com/henryiii/validate-pyproject-schema-store/compare/2024.08.08...2024.08.19) --- .pre-commit-config.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 06ef681..914eba9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,7 +58,7 @@ repos: # Python linting using ruff - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.1 + rev: v0.6.2 hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -68,7 +68,7 @@ repos: # Static type checking using mypy - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.1 + rev: v1.11.2 hooks: - id: mypy files: ^(src/mqt|tests) @@ -93,7 +93,7 @@ repos: # Check for spelling - repo: https://github.com/crate-ci/typos - rev: v1.23.6 + rev: v1.24.1 hooks: - id: typos @@ -108,14 +108,14 @@ repos: # Check best practices for scientific Python code - repo: https://github.com/scientific-python/cookie - rev: 2024.04.23 + rev: 2024.08.19 hooks: - id: sp-repo-review additional_dependencies: ["repo-review[cli]"] # Check JSON schemata - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.29.1 + rev: 0.29.2 hooks: - id: check-dependabot - id: check-github-workflows @@ -123,6 +123,6 @@ repos: # Check the pyproject.toml file - repo: https://github.com/henryiii/validate-pyproject-schema-store - rev: 2024.08.08 + rev: 2024.08.19 hooks: - id: validate-pyproject From fc18e0a4e9b98e49d106ab18ae820dd45ef98fac Mon Sep 17 00:00:00 2001 From: DeborahVolpe Date: Thu, 29 Aug 2024 13:24:06 +0200 Subject: [PATCH 4/9] update configuration for precommit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0af04ed..6ba686a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -71,7 +71,7 @@ repos: rev: v1.10.0 hooks: - id: mypy - files: ^(src/mqt|tests) + files: ^(mqt|tests) args: [] additional_dependencies: - pytest From c247ccfad98e3976b4e3ebe4f15b6192b5e4dc62 Mon Sep 17 00:00:00 2001 From: DeborahVolpe Date: Thu, 29 Aug 2024 13:26:29 +0200 Subject: [PATCH 5/9] update configuration for precommit --- scripts/Knapsack/Knapsack.py | 2 +- scripts/linear_regression/LinearRegression.py | 6 +++--- tests/test_evaluation.py | 9 ++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/Knapsack/Knapsack.py b/scripts/Knapsack/Knapsack.py index 78b7dd4..0022078 100644 --- a/scripts/Knapsack/Knapsack.py +++ b/scripts/Knapsack/Knapsack.py @@ -6,10 +6,10 @@ from typing import cast import numpy as np -from sympy import Expr # for managing symbols from mqt.qao import Constraints, ObjectiveFunction, Problem, Solver, Variables +from sympy import Expr lambdas_method = [ "upper_bound_only_positive", diff --git a/scripts/linear_regression/LinearRegression.py b/scripts/linear_regression/LinearRegression.py index 46231b5..4149e93 100644 --- a/scripts/linear_regression/LinearRegression.py +++ b/scripts/linear_regression/LinearRegression.py @@ -4,12 +4,12 @@ import numpy as np import pandas as pd -from sklearn.decomposition import PCA -from sklearn.utils import shuffle -from sympy import Expr # for managing symbols from mqt.qao import Constraints, ObjectiveFunction, Problem, Solver, Variables +from sklearn.decomposition import PCA +from sklearn.utils import shuffle +from sympy import Expr df = pd.read_csv("iris_csv.csv") df = shuffle(df) diff --git a/tests/test_evaluation.py b/tests/test_evaluation.py index b69bd34..5634972 100644 --- a/tests/test_evaluation.py +++ b/tests/test_evaluation.py @@ -6,17 +6,16 @@ import numpy as np import pytest - -# for managing symbols -from qubovert import PUBO, boolean_var -from sympy import Expr - from mqt.qao.constraints import Constraints from mqt.qao.objectivefunction import ObjectiveFunction from mqt.qao.problem import Problem from mqt.qao.solvers import Solution, Solver from mqt.qao.variables import Variables +# for managing symbols +from qubovert import PUBO, boolean_var +from sympy import Expr + def test_binary_only() -> None: """Test only the construction of binary variables""" From 91d8f3c5ecc2f2670e7d8cb2705279b6f789fb31 Mon Sep 17 00:00:00 2001 From: DeborahVolpe Date: Thu, 29 Aug 2024 13:36:22 +0200 Subject: [PATCH 6/9] update configuration for precommit --- pyproject.toml | 1 - scripts/Knapsack/Knapsack.py | 2 +- scripts/linear_regression/LinearRegression.py | 6 +++--- tests/test_evaluation.py | 9 +++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 14e4fc4..822be86 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -140,7 +140,6 @@ ignore_missing_imports = true [tool.ruff] line-length = 120 -src = ["src"] preview = true unsafe-fixes = true diff --git a/scripts/Knapsack/Knapsack.py b/scripts/Knapsack/Knapsack.py index 0022078..78b7dd4 100644 --- a/scripts/Knapsack/Knapsack.py +++ b/scripts/Knapsack/Knapsack.py @@ -6,10 +6,10 @@ from typing import cast import numpy as np +from sympy import Expr # for managing symbols from mqt.qao import Constraints, ObjectiveFunction, Problem, Solver, Variables -from sympy import Expr lambdas_method = [ "upper_bound_only_positive", diff --git a/scripts/linear_regression/LinearRegression.py b/scripts/linear_regression/LinearRegression.py index 0725bf6..724e03e 100644 --- a/scripts/linear_regression/LinearRegression.py +++ b/scripts/linear_regression/LinearRegression.py @@ -4,13 +4,13 @@ import numpy as np import pandas as pd - -# for managing symbols -from mqt.qao import Constraints, ObjectiveFunction, Problem, Solver, Variables from sklearn.decomposition import PCA from sklearn.utils import shuffle from sympy import Expr +# for managing symbols +from mqt.qao import Constraints, ObjectiveFunction, Problem, Solver, Variables + df = pd.read_csv("iris_csv.csv") df = shuffle(df) d = len(df.columns) - 1 diff --git a/tests/test_evaluation.py b/tests/test_evaluation.py index e4b89af..ccc809b 100644 --- a/tests/test_evaluation.py +++ b/tests/test_evaluation.py @@ -7,16 +7,17 @@ import numpy as np import pytest + +# for managing symbols +from qubovert import PUBO, boolean_var +from sympy import Expr + from mqt.qao.constraints import Constraints from mqt.qao.objectivefunction import ObjectiveFunction from mqt.qao.problem import Problem from mqt.qao.solvers import Solution, Solver from mqt.qao.variables import Variables -# for managing symbols -from qubovert import PUBO, boolean_var -from sympy import Expr - def test_binary_only() -> None: """Test only the construction of binary variables""" From e605202810034fac2542469c29313fbcce66b720 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:39:47 +0000 Subject: [PATCH 7/9] =?UTF-8?q?=E2=AC=86=EF=B8=8F=F0=9F=AA=9D=20update=20p?= =?UTF-8?q?re-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.1 → v0.6.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.1...v0.6.4) - [github.com/pre-commit/mirrors-mypy: v1.11.1 → v1.11.2](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.1...v1.11.2) - [github.com/crate-ci/typos: v1.23.6 → v1.24.5](https://github.com/crate-ci/typos/compare/v1.23.6...v1.24.5) - [github.com/scientific-python/cookie: 2024.04.23 → 2024.08.19](https://github.com/scientific-python/cookie/compare/2024.04.23...2024.08.19) - [github.com/python-jsonschema/check-jsonschema: 0.29.1 → 0.29.2](https://github.com/python-jsonschema/check-jsonschema/compare/0.29.1...0.29.2) - [github.com/henryiii/validate-pyproject-schema-store: 2024.08.08 → 2024.08.26](https://github.com/henryiii/validate-pyproject-schema-store/compare/2024.08.08...2024.08.26) --- .pre-commit-config.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 06ef681..94325b6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,7 +58,7 @@ repos: # Python linting using ruff - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.1 + rev: v0.6.4 hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -68,7 +68,7 @@ repos: # Static type checking using mypy - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.1 + rev: v1.11.2 hooks: - id: mypy files: ^(src/mqt|tests) @@ -93,7 +93,7 @@ repos: # Check for spelling - repo: https://github.com/crate-ci/typos - rev: v1.23.6 + rev: v1.24.5 hooks: - id: typos @@ -108,14 +108,14 @@ repos: # Check best practices for scientific Python code - repo: https://github.com/scientific-python/cookie - rev: 2024.04.23 + rev: 2024.08.19 hooks: - id: sp-repo-review additional_dependencies: ["repo-review[cli]"] # Check JSON schemata - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.29.1 + rev: 0.29.2 hooks: - id: check-dependabot - id: check-github-workflows @@ -123,6 +123,6 @@ repos: # Check the pyproject.toml file - repo: https://github.com/henryiii/validate-pyproject-schema-store - rev: 2024.08.08 + rev: 2024.08.26 hooks: - id: validate-pyproject From 39f2f6e986d817b273030ab286b4e9844dabfd43 Mon Sep 17 00:00:00 2001 From: DeborahVolpe Date: Fri, 13 Sep 2024 16:06:56 +0200 Subject: [PATCH 8/9] update configuration for precommit --- src/mqt/qao/solvers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mqt/qao/solvers.py b/src/mqt/qao/solvers.py index aa3955c..b83995f 100644 --- a/src/mqt/qao/solvers.py +++ b/src/mqt/qao/solvers.py @@ -1265,7 +1265,7 @@ def check_constraint_optimal_solution(self, weak: bool = False) -> tuple[bool, l Return values: constraints_satisfy -- bool which is equal to True if all the constraints are satisfied - single_constraint_satisfy -- list of bool, saying which are the satisfied constraint and which are not + single_constraint_satisfy -- list of bool, saying which are the satisfied constraint and which are not satisfied """ self.constraints_satisfy, self.single_constraint_satisfy = self.problem.constraints.check_constraint( From 09127a0585bd23068bc4313f95d66767635ae102 Mon Sep 17 00:00:00 2001 From: DeborahVolpe Date: Fri, 13 Sep 2024 20:02:02 +0200 Subject: [PATCH 9/9] update configuration for precommit --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 822be86..8963bca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,6 @@ dependencies = [ "qiskit>=1.0", "qiskit_optimization>=0.6", "qiskit_aer>=0.14", - "qiskit_aer<0.14.1; python_version < '3.10'", # temporarily upper cap because of https://github.com/Qiskit/qiskit-aer/issues/2167 "pandas>=2.1.2", "numpy>=1.26", "qubovert>=1.2.5",