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 #23

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 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.4.3
rev: v0.4.4
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down Expand Up @@ -86,7 +86,7 @@ repos:

# Clang-format the C++ part of the code base automatically
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.4
rev: v18.1.5
hooks:
- id: clang-format
types_or: [c++, c, cuda]
Expand Down
3 changes: 2 additions & 1 deletion include/dd/ComplexTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@
}
};

static inline Entry zero{

Check warning on line 105 in include/dd/ComplexTable.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/dd/ComplexTable.hpp:105:23 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'zero' is non-const and globally accessible, consider making it const
0., nullptr,
1}; // NOLINT(readability-identifier-naming,cppcoreguidelines-avoid-non-const-global-variables)
// automatic renaming does not work reliably, so skip linting
static inline Entry sqrt2_2{

Check warning on line 109 in include/dd/ComplexTable.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/dd/ComplexTable.hpp:109:23 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'sqrt2_2' is non-const and globally accessible, consider making it const

Check warning on line 109 in include/dd/ComplexTable.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/dd/ComplexTable.hpp:109:23 [readability-identifier-naming]

invalid case style for variable 'sqrt2_2'
SQRT2_2, nullptr,
1}; // NOLINT(readability-identifier-naming,cppcoreguidelines-avoid-non-const-global-variables)
// automatic renaming does not work reliably, so skip linting
static inline Entry one{

Check warning on line 113 in include/dd/ComplexTable.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/dd/ComplexTable.hpp:113:23 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'one' is non-const and globally accessible, consider making it const
1., nullptr,
1}; // NOLINT(readability-identifier-naming,cppcoreguidelines-avoid-non-const-global-variables)
// automatic renaming does not work reliably, so skip linting
Expand Down Expand Up @@ -426,7 +426,8 @@
for (std::size_t key = 0; key < table.size(); ++key) {
auto p = table[key];
if (p != nullptr) {
std::cout << key << ": " << "\n";
std::cout << key << ": "
<< "\n";
}

while (p != nullptr) {
Expand Down Expand Up @@ -519,7 +520,7 @@
std::size_t upperNeighbors = 0;

// numerical tolerance to be used for floating point values
static inline fp TOLERANCE =

Check warning on line 523 in include/dd/ComplexTable.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/dd/ComplexTable.hpp:523:20 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'TOLERANCE' is non-const and globally accessible, consider making it const

Check warning on line 523 in include/dd/ComplexTable.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/dd/ComplexTable.hpp:523:20 [readability-identifier-naming]

invalid case style for variable 'TOLERANCE'
std::numeric_limits<dd::fp>::epsilon() *
1024; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables,readability-identifier-naming)

Expand Down
3 changes: 2 additions & 1 deletion include/dd/UniqueTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
assert(edge.nextNode->varIndx == v - 1 || edge.isTerminal());
}

Node* p = tables[static_cast<std::size_t>(v)][key];

Check warning on line 103 in include/dd/UniqueTable.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/dd/UniqueTable.hpp:103:11 [cppcoreguidelines-init-variables]

variable 'p' is not initialized
while (p != nullptr) {
if (e.nextNode->edges == p->edges) {
// Match found
Expand Down Expand Up @@ -234,8 +234,8 @@
}

gcRuns++;
std::size_t collected = 0;

Check warning on line 237 in include/dd/UniqueTable.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/dd/UniqueTable.hpp:237:5 [misc-const-correctness]

variable 'collected' of type 'std::size_t' (aka 'unsigned long') can be declared 'const'
std::size_t remaining = 0;

Check warning on line 238 in include/dd/UniqueTable.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/dd/UniqueTable.hpp:238:5 [misc-const-correctness]

variable 'remaining' of type 'std::size_t' (aka 'unsigned long') can be declared 'const'
for (auto& table : tables) {
for (auto& bucket : table) {
Node* p = bucket;
Expand Down Expand Up @@ -323,7 +323,8 @@
QuantumRegister q = nvars - 1;
for (auto it = tables.rbegin(); it != tables.rend(); ++it) {
auto& table = *it;
std::cout << "\tq" << static_cast<std::size_t>(q) << ":" << "\n";
std::cout << "\tq" << static_cast<std::size_t>(q) << ":"
<< "\n";
for (std::size_t key = 0; key < table.size(); ++key) {
auto p = table[key];
if (p != nullptr) {
Expand Down
3 changes: 2 additions & 1 deletion src/mqt/qudits/quantum_circuit/circuit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import copy
import locale
from pathlib import Path
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -378,7 +379,7 @@ def load_from_file(self, file_path: str) -> None:
Returns:
str: The text loaded from the file.
"""
with Path(file_path).open("r") as file:
with Path(file_path).open("r", encoding=locale.getpreferredencoding(False)) as file:
text = file.read()
self.from_qasm(text)

Expand Down
21 changes: 14 additions & 7 deletions test/data_collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,8 @@ int main() { // NOLINT(bugprone-exception-escape)
fullMixWState(myfile, {2, 3, 2, 5});
fullMixWState(myfile, {2, 3, 3, 3});
fullMixWState(myfile, {5, 5, 2, 2});
std::cout << "First set" << "\n";
std::cout << "First set"
<< "\n";
myfile.close();
myfile.open("/home/k3vn/Desktop/trycollect.csv", std::ios_base::app);

Expand All @@ -478,7 +479,8 @@ int main() { // NOLINT(bugprone-exception-escape)
ghzQutritStateScaled(myfile, 60);
ghzQutritStateScaled(myfile, 120);
ghzQutritStateScaled(myfile, 128);
std::cout << "Second set" << "\n";
std::cout << "Second set"
<< "\n";
myfile.close();
myfile.open("/home/k3vn/Desktop/trycollect.csv", std::ios_base::app);
randomCircuits(3, 1000, myfile);
Expand All @@ -487,7 +489,8 @@ int main() { // NOLINT(bugprone-exception-escape)
randomCircuits(6, 1000, myfile);
randomCircuits(7, 1000, myfile);

std::cout << "Third set" << "\n";
std::cout << "Third set"
<< "\n";
myfile.close();
myfile.open("/home/k3vn/Desktop/trycollect.csv", std::ios_base::app);
randomCircuits(3, 1000, myfile);
Expand All @@ -496,7 +499,8 @@ int main() { // NOLINT(bugprone-exception-escape)
randomCircuits(6, 1000, myfile);
randomCircuits(7, 1000, myfile);

std::cout << "fourth set" << "\n";
std::cout << "fourth set"
<< "\n";
myfile.close();
myfile.open("/home/k3vn/Desktop/trycollect.csv", std::ios_base::app);
randomCircuits(3, 1000, myfile);
Expand All @@ -505,7 +509,8 @@ int main() { // NOLINT(bugprone-exception-escape)
randomCircuits(6, 1000, myfile);
randomCircuits(7, 1000, myfile);

std::cout << "fifth set" << "\n";
std::cout << "fifth set"
<< "\n";
myfile.close();
myfile.open("/home/k3vn/Desktop/trycollect.csv", std::ios_base::app);
randomCircuits(8, 1000, myfile);
Expand All @@ -515,7 +520,8 @@ int main() { // NOLINT(bugprone-exception-escape)
randomCircuits(12, 1000, myfile);
randomCircuits(13, 1000, myfile);

std::cout << "6 set" << "\n";
std::cout << "6 set"
<< "\n";
myfile.close();
myfile.open("/home/k3vn/Desktop/trycollect.csv", std::ios_base::app);
randomCircuits(8, 1000, myfile);
Expand All @@ -525,7 +531,8 @@ int main() { // NOLINT(bugprone-exception-escape)
randomCircuits(12, 1000, myfile);
randomCircuits(13, 1000, myfile);

std::cout << "7 set" << "\n";
std::cout << "7 set"
<< "\n";

myfile.close();
return 0;
Expand Down
18 changes: 12 additions & 6 deletions test/test_pkg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,8 @@ TEST(DDPackageTest, RandomCircuits) {
auto evolution = dd->makeZeroState(width);

std::cout << "\n"
<< "STARTED" << "\n"
<< "STARTED"
<< "\n"
<< std::endl;

std::uniform_int_distribution<> pickbool(0, 1);
Expand All @@ -851,7 +852,8 @@ TEST(DDPackageTest, RandomCircuits) {

if (localChoice == 0) { // hadamard
std::cout << "\n"
<< "hadamard" << "\n"
<< "hadamard"
<< "\n"
<< std::endl;
if (particles.at(line) == 2) {
auto chosenGate = dd->makeGateDD<dd::GateMatrix>(
Expand All @@ -872,7 +874,8 @@ TEST(DDPackageTest, RandomCircuits) {
}
} else { // givens
std::cout << "\n"
<< "givens" << "\n"
<< "givens"
<< "\n"
<< std::endl;
if (particles.at(line) == 2) {
double const theta = 0.;
Expand Down Expand Up @@ -936,7 +939,8 @@ TEST(DDPackageTest, RandomCircuits) {
}
} else { // entangling
std::cout << "\n"
<< "entangling" << "\n"
<< "entangling"
<< "\n"
<< std::endl;

auto entChoice = pickbool(gen);
Expand Down Expand Up @@ -970,7 +974,8 @@ TEST(DDPackageTest, RandomCircuits) {
if (entChoice == 0) { // CEX based
// selection of controls
std::cout << "\n"
<< "CEX" << "\n"
<< "CEX"
<< "\n"
<< std::endl;
if (particles.at(line) == 2) {
double const theta = angles(gen);
Expand Down Expand Up @@ -1033,7 +1038,8 @@ TEST(DDPackageTest, RandomCircuits) {
}
} else { // Controlled clifford
std::cout << "\n"
<< "clifford" << "\n"
<< "clifford"
<< "\n"
<< std::endl;
if (particles.at(line) == 2) {
auto chosenGate = dd->makeGateDD<dd::GateMatrix>(
Expand Down
Loading