Skip to content

Commit

Permalink
fix minor ci build issues
Browse files Browse the repository at this point in the history
* removed squeaky unit test
* converted illegal char* uses to std::string in diagnostics
* address some signed/unsigned comparisons
  • Loading branch information
boothby authored Dec 8, 2020
1 parent c10ce49 commit 6338043
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 27 deletions.
12 changes: 6 additions & 6 deletions include/find_embedding/embedding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ template <typename embedding_problem_t>
class embedding {
public:
#ifdef CPPDEBUG
char *last_diagnostic;
std::string last_diagnostic;
#endif
private:
embedding_problem_t &ep;
Expand All @@ -63,7 +63,7 @@ class embedding {
embedding(embedding_problem_t &e_p)
:
#ifdef CPPDEBUG
last_diagnostic(nullptr),
last_diagnostic(""),
#endif
ep(e_p),
num_qubits(ep.num_qubits()),
Expand Down Expand Up @@ -124,7 +124,7 @@ class embedding {
inline const chain &get_chain(int v) const { return var_embedding[v]; }

//! Get the size of a chain
inline int chainsize(int v) const { return var_embedding[v].size(); }
inline unsigned int chainsize(int v) const { return var_embedding[v].size(); }

//! Get the weight of a qubit
inline int weight(int q) const { return qub_weight[q]; }
Expand Down Expand Up @@ -369,7 +369,7 @@ class embedding {

//! run a long diagnostic, and if debugging is enabled, record `current_state` so that the
//! error message has a little more context. if an error is found, throw a CorruptEmbeddingException
void long_diagnostic(char *current_state) {
void long_diagnostic(std::string current_state) {
run_long_diagnostic(current_state);
#ifdef CPPDEBUG
last_diagnostic = current_state;
Expand All @@ -378,7 +378,7 @@ class embedding {

//! run a long diagnostic to verify the integrity of this datastructure. the guts of this function
//! are its documentation, because this function only exists for debugging purposes
void run_long_diagnostic(char *current_state) const {
void run_long_diagnostic(std::string current_state) const {
int err = 0;
vector<int> tmp_weight(num_qubits + num_reserved, 0);
int zeros = 0;
Expand Down Expand Up @@ -544,7 +544,7 @@ class embedding {
if (err) {
ep.error("errors found in data structure, current state is '%s'. quitting\n", current_state);
#ifdef CPPDEBUG
if (last_diagnostic != nullptr) ep.debug("last state was %s\n", last_diagnostic);
if (last_diagnostic.size()) ep.debug("last state was %s\n", last_diagnostic);
#endif
print();
throw CorruptEmbeddingException("Errors found in embedding data structure. Cannot recover.");
Expand Down
22 changes: 11 additions & 11 deletions include/find_embedding/find_embedding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ namespace find_embedding {

class parameter_processor {
public:
int num_vars;
int num_qubits;
unsigned int num_vars;
unsigned int num_qubits;

vector<int> qub_reserved_unscrewed;
vector<int> var_fixed_unscrewed;
int num_reserved;
unsigned int num_reserved;

graph::components qub_components;
int problem_qubits;
int problem_reserved;
unsigned int problem_qubits;
unsigned int problem_reserved;

int num_fixed;
unsigned int num_fixed;
vector<int> unscrew_vars;
vector<int> screw_vars;

Expand Down Expand Up @@ -69,8 +69,8 @@ class parameter_processor {
qubit_nbrs(qub_components.component_neighbors(0)) {}

private:
inline int _reserved(optional_parameters &params_) {
int r = 0;
inline unsigned int _reserved(optional_parameters &params_) {
unsigned int r = 0;
for (auto &vC : params_.fixed_chains) {
var_fixed_unscrewed[vC.first] = 1;
for (auto &q : vC.second) {
Expand All @@ -87,7 +87,7 @@ class parameter_processor {
vector<int> unscrew(num_vars);
assert(var_fixed_unscrewed.size() == num_vars);
assert(num_fixed < num_vars);
for (int i = 0, front = 0, back = num_vars - num_fixed; i < num_vars; i++) {
for (unsigned int i = 0, front = 0, back = num_vars - num_fixed; i < num_vars; i++) {
if (var_fixed_unscrewed[i]) {
unscrew[back++] = i;
} else {
Expand All @@ -110,7 +110,7 @@ class parameter_processor {
map<int, vector<int>> input_chains(map<int, vector<int>> &m) {
map<int, vector<int>> n;
for (auto &kv : m) {
if (kv.first < 0 || kv.first >= num_vars) throw CorruptParametersException();
if (kv.first < 0 || static_cast<unsigned int>(kv.first) >= num_vars) throw CorruptParametersException();
auto &ju = *(n.emplace(screw_vars[kv.first], vector<int>{}).first);
if (!qub_components.into_component(0, kv.second, ju.second)) {
throw CorruptParametersException();
Expand All @@ -122,7 +122,7 @@ class parameter_processor {
vector<int> input_vars(vector<int> &V) {
vector<int> U;
for (auto &v : V) {
if (v < 0 || v >= num_vars) throw CorruptParametersException();
if (v < 0 || static_cast<unsigned int>(v) >= num_vars) throw CorruptParametersException();
if (!var_fixed_unscrewed[v]) U.push_back(v);
}
return U;
Expand Down
2 changes: 1 addition & 1 deletion include/find_embedding/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class components {
for (auto& x : nodes_in) {
try {
if (index.at(x) != c) return false;
} catch (std::out_of_range& _) {
} catch (std::out_of_range& /*e*/) {
return false;
}
nodes_out.push_back(label[x]);
Expand Down
5 changes: 3 additions & 2 deletions include/find_embedding/pathfinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class pathfinder_base : public pathfinder_public_interface {
} catch (const TimeoutException & /*e*/) {
ep.major_info("problem timed out");
return -2;
} catch (const ProblemCancelledException &e) {
} catch (const ProblemCancelledException & /*e*/) {
ep.major_info("problem cancelled via keyboard interrupt");
if (params.interactive)
return -2;
Expand Down Expand Up @@ -574,7 +574,8 @@ class pathfinder_base : public pathfinder_public_interface {
}

if (got) {
if (bestEmbedding.chainsize(u) > chainlength_bound && chainlength_bound > 0) {
if (chainlength_bound > 0 &&
bestEmbedding.chainsize(u) > static_cast<unsigned int>(chainlength_bound)) {
bestEmbedding.steal_all(u);
bestEmbedding.tear_out(u);
}
Expand Down
7 changes: 0 additions & 7 deletions minorminer/utils/tests/test_polynomialembedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,6 @@ def test_evil_K_2_2(self):
emb = proc.tightestNativeBiClique(1, 1)
verify_biclique(proc, emb, 1, 1, 1, 1)

for _ in range(100): # this should be plenty
proc = processor(couplers, M=2, N=2, L=4, linear=False, proc_limit=4)
emb = proc.tightestNativeBiClique(1, 1)
if emb is not None:
break
verify_biclique(proc, emb, 1, 1, 1, 1)

def test_objectives(self):
couplers = [((0, 0, 0, i), (1, 0, 0, i)) for i in range(4)]
couplers += [((0, 0, 1, i), (0, 1, 1, i)) for i in range(4)]
Expand Down

0 comments on commit 6338043

Please sign in to comment.