Skip to content

Commit

Permalink
fix: ♻️ Fix mypy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DRovara committed Oct 9, 2024
1 parent e8ca40f commit 4a4d962
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ report.exclude_also = [
[tool.mypy]
mypy_path = "$MYPY_CONFIG_FILE_DIR/src,$MYPY_CONFIG_FILE_DIR/stubs"
files = ["src", "tests"]
python_version = "3.8"
python_version = "3.9"
strict = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = true
explicit_package_bases = true
pretty = true

[[tool.mypy.overrides]]
module = ["types-Pillow", "jsonschema", "tsplib95.*", "ipywidgets.*", "IPython.*", "qiskit.*", "qiskit_algorithms.*", "matplotlib.*", "networkx.*", "mqt.ddsim.*", "joblib.*", "qiskit_optimization.*", "docplex.*", "typing_extensions.*"]
module = ["types-Pillow", "jsonschema", "tsplib95.*", "ipywidgets.*", "IPython.*", "qiskit.*", "qiskit_algorithms.*", "matplotlib.*", "networkx.*", "mqt.ddsim.*", "joblib.*", "qiskit_optimization.*", "docplex.*", "typing_extensions.*", "numpy.*"]
ignore_missing_imports = true

[tool.ruff]
Expand Down
4 changes: 2 additions & 2 deletions src/mqt/qubomaker/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Tuple, Union
from typing import TYPE_CHECKING, Tuple, Union, cast

import networkx as nx
import numpy as np
Expand Down Expand Up @@ -162,7 +162,7 @@ def __eq__(self, value: object) -> bool:
"""
if not isinstance(value, Graph):
return False
return np.array_equal(self.adjacency_matrix, value.adjacency_matrix)
return cast(bool, np.array_equal(self.adjacency_matrix, value.adjacency_matrix))

def __hash__(self) -> int:
"""Returns the hash of the graph.
Expand Down
2 changes: 1 addition & 1 deletion src/mqt/qubomaker/pathfinder/cost_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ def get_variable_function(p: Any, v: Any, i: Any, _n: int = 0) -> sp.Expr:
@override
def get_formula_domain_wall(self, graph: Graph, settings: pathfinder.PathFindingQUBOGeneratorSettings) -> sp.Expr:
general = self.get_formula_general(graph, settings, FormulaHelpers.get_encoding_variable_domain_wall)
enforce_domain_wall_penalty = (
enforce_domain_wall_penalty: sp.Expr = (
2 * settings.max_path_length * np.max(graph.adjacency_matrix) + graph.n_vertices**2
)
# This ensures that the domain wall condition (x_i = 0 -> x_{i+1} = 0) is not broken to achieve better cost in other cost functions.
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/graph/graph
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
0. 0. 0. 3. 0.
0. 0. 0. 0. 2.
0. 0. 0. 0. 5.
1. 0. 0. 0. 0.
1. 0. 0. 0. 0.

0 comments on commit 4a4d962

Please sign in to comment.