-
Notifications
You must be signed in to change notification settings - Fork 34
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
♻️🎨 Code cleanup and refactors #798
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: burgholzer <[email protected]>
- opting for references where null values are not expected or accepted. - moving code from headers to source files. - fixing new clang-tidy warnings - adding a little more noexcept were appropriate Signed-off-by: burgholzer <[email protected]>
Signed-off-by: burgholzer <[email protected]>
Replaced raw pointer usages with references across the codebase for improved clarity and type safety. This adjustment simplifies operations and ensures consistency, particularly when applying, measuring, or resetting operations in simulation and functionality logic. Corresponding tests have been updated to reflect this change. Signed-off-by: burgholzer <[email protected]>
This is only used in one part of DDSIM that is scheduled for removal. And removed code is debugged code. Signed-off-by: burgholzer <[email protected]>
Signed-off-by: burgholzer <[email protected]>
these members had getters since a while back. there is no need to keep them as public members. Signed-off-by: burgholzer <[email protected]>
@@ -38,17 +38,17 @@ | |||
const auto nq = GetParam(); | |||
|
|||
auto dd = std::make_unique<dd::Package<>>(nq); | |||
auto qc = qc::RandomCliffordCircuit(nq, nq * nq, 12345); | |||
auto qc = qc::createRandomCliffordCircuit(nq, nq * nq, 12345); |
Check failure
Code scanning / CodeQL
Multiplication result converted to larger type High test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 24 hours ago
To fix the problem, we need to ensure that the multiplication is performed using the larger type std::size_t
to avoid overflow. This can be done by casting one of the operands to std::size_t
before performing the multiplication. This ensures that the multiplication is done in the larger type, preventing overflow.
- Cast
nq
tostd::size_t
before performing the multiplication. - Update the relevant lines in the file
test/algorithms/test_random_clifford.cpp
.
-
Copy modified line R41 -
Copy modified line R51
@@ -40,3 +40,3 @@ | ||
auto dd = std::make_unique<dd::Package<>>(nq); | ||
auto qc = qc::createRandomCliffordCircuit(nq, nq * nq, 12345); | ||
auto qc = qc::createRandomCliffordCircuit(nq, static_cast<std::size_t>(nq) * nq, 12345); | ||
auto in = dd->makeZeroState(nq); | ||
@@ -50,3 +50,3 @@ | ||
auto dd = std::make_unique<dd::Package<>>(nq); | ||
auto qc = qc::createRandomCliffordCircuit(nq, nq * nq, 12345); | ||
auto qc = qc::createRandomCliffordCircuit(nq, static_cast<std::size_t>(nq) * nq, 12345); | ||
ASSERT_NO_THROW({ dd::buildFunctionality(qc, *dd); }); |
qc.printStatistics(std::cout); | ||
} | ||
|
||
TEST_P(RandomClifford, buildFunctionality) { | ||
const auto nq = GetParam(); | ||
|
||
auto dd = std::make_unique<dd::Package<>>(nq); | ||
auto qc = qc::RandomCliffordCircuit(nq, nq * nq, 12345); | ||
ASSERT_NO_THROW({ dd::buildFunctionality(&qc, *dd); }); | ||
auto qc = qc::createRandomCliffordCircuit(nq, nq * nq, 12345); |
Check failure
Code scanning / CodeQL
Multiplication result converted to larger type High test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 24 hours ago
To fix the problem, we need to ensure that the multiplication is performed using the larger integer type to avoid overflow. This can be done by casting one of the operands to std::size_t
before performing the multiplication. Specifically, we will cast nq
to std::size_t
in the multiplication expression nq * nq
on line 51.
-
Copy modified line R41 -
Copy modified line R51
@@ -40,3 +40,3 @@ | ||
auto dd = std::make_unique<dd::Package<>>(nq); | ||
auto qc = qc::createRandomCliffordCircuit(nq, nq * nq, 12345); | ||
auto qc = qc::createRandomCliffordCircuit(nq, static_cast<std::size_t>(nq) * nq, 12345); | ||
auto in = dd->makeZeroState(nq); | ||
@@ -50,3 +50,3 @@ | ||
auto dd = std::make_unique<dd::Package<>>(nq); | ||
auto qc = qc::createRandomCliffordCircuit(nq, nq * nq, 12345); | ||
auto qc = qc::createRandomCliffordCircuit(nq, static_cast<std::size_t>(nq) * nq, 12345); | ||
ASSERT_NO_THROW({ dd::buildFunctionality(qc, *dd); }); |
Cpp-Linter Report
|
Description
Starting the year with some obligatory code cleanup and refactors.
The individual commits and the commit messages should more or less convey the bigger changes.
For the most part, it's really all about defining clearer interfaces and following some new clang-tidy suggestions.
Checklist: