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

⬆️🪝 update pre-commit hooks #48

Merged
merged 4 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ repos:

# Python linting using ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
rev: v0.8.1
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down Expand Up @@ -86,14 +86,14 @@ repos:

# Format configuration files with prettier
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.3.3
rev: v3.4.1
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]

# Check for spelling
- repo: https://github.com/crate-ci/typos
rev: typos-dict-v0.11.35
rev: v1.28.1
hooks:
- id: typos

Expand All @@ -115,14 +115,14 @@ repos:

# Check JSON schemata
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.4
rev: 0.30.0
hooks:
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs

# Check the pyproject.toml file
- repo: https://github.com/henryiii/validate-pyproject-schema-store
rev: 2024.11.18
rev: 2024.11.25
hooks:
- id: validate-pyproject
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,17 @@ extend-select = [
"SLF", # flake8-self
"SLOT", # flake8-slots
"SIM", # flake8-simplify
"TCH", # flake8-type-checking
"TC", # flake8-type-checking
"TID251", # flake8-tidy-imports.banned-api
"TRY", # tryceratops
"UP", # pyupgrade
"YTT", # flake8-2020
]
ignore = [
"ANN101", # Missing type annotation for `self` in method
"ANN102", # Missing type annotation for `cls` in classmethod
"ISC001", # Conflicts with formatter
"PLR09", # Too many <...>
"PLR2004", # Magic value used in comparison
"PLC0415", # Import should be at top of file
"PT004", # Incorrect, just usefixtures instead.
"S101", # Use of assert detected
"S404", # `subprocess` module is possibly insecure
]
Expand Down
14 changes: 7 additions & 7 deletions scripts/Knapsack/Knapsack.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from __future__ import annotations

import locale
import os
from pathlib import Path
from typing import cast
from typing import TYPE_CHECKING, cast

import numpy as np
from sympy import Expr

# for managing symbols
from mqt.qao import Constraints, ObjectiveFunction, Problem, Solver, Variables

if TYPE_CHECKING:
from sympy import Expr
Dismissed Show dismissed Hide dismissed

lambdas_method = [
"upper_bound_only_positive",
"maximum_coefficient",
Expand Down Expand Up @@ -44,8 +45,7 @@
("upper lower bound posiform and negaform method", "binary search penalty algorithm"),
]

files = os.listdir("Data/")
for file in files:
for file in Path("Data/").iterdir():
print(file)
with Path("./Data/" + file).open("r", encoding=locale.getpreferredencoding(False)) as f:
lines = f.readlines()
Expand All @@ -65,7 +65,7 @@
variables = Variables()
obj = variables.add_binary_variables_array("obj", [objects])
objective_function = ObjectiveFunction()
objective_function.add_objective_function(cast(Expr, np.dot(np.transpose(obj), p_arr)), minimization=False)
objective_function.add_objective_function(cast("Expr", np.dot(np.transpose(obj), p_arr)), minimization=False)
constraint = Constraints()
constraint.add_constraint(str(np.dot(np.transpose(obj), w_arr)) + " <= " + format(W_max))
problem = Problem()
Expand All @@ -85,7 +85,7 @@
variables = Variables()
obj = variables.add_binary_variables_array("obj", [objects])
objective_function = ObjectiveFunction()
objective_function.add_objective_function(cast(Expr, np.dot(np.transpose(obj), p_arr)), minimization=False)
objective_function.add_objective_function(cast("Expr", np.dot(np.transpose(obj), p_arr)), minimization=False)
constraint = Constraints()
constraint.add_constraint(str(np.dot(np.transpose(obj), w_arr)) + " <= " + format(W_max))
problem = Problem()
Expand Down
8 changes: 5 additions & 3 deletions scripts/linear_regression/LinearRegression.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from __future__ import annotations

from typing import cast
from typing import TYPE_CHECKING, cast

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

if TYPE_CHECKING:
from sympy import Expr
Dismissed Show dismissed Hide dismissed

df = pd.read_csv("iris_csv.csv")
df = shuffle(df)
d = len(df.columns) - 1
Expand Down Expand Up @@ -48,7 +50,7 @@
objective_function = ObjectiveFunction()
objective_function.add_objective_function(
cast(
Expr,
"Expr",
(
np.dot(np.dot(np.dot(np.transpose(w), np.transpose(X_training)), X_training), w)
- 2 * np.dot(np.dot(np.transpose(w), np.transpose(X_training)), Y_training)
Expand Down
Loading
Loading