Skip to content

Commit 54face8

Browse files
committed
Switch to eprint for vebosity message in InflationSDP and InflationLP
1 parent 68f7c0d commit 54face8

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

inflation/lp/InflationLP.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,13 @@ def __init__(self,
169169
self._boolvec_for_FR_eqs = self.blank_bool_vec
170170

171171
if self.verbose > 1:
172-
print("Number of single operator measurements per party:", end="")
172+
eprint("Number of single operator measurements per party:", end="")
173173
prefix = " "
174174
for i, measures in enumerate(inflationproblem.measurements):
175175
op_count = np.prod(measures.shape[:2])
176-
print(prefix + f"{self.names[i]}={op_count}", end="")
176+
eprint(prefix + f"{self.names[i]}={op_count}", end="")
177177
prefix = ", "
178-
print()
178+
eprint()
179179
self.use_lpi_constraints = False
180180

181181
self.identity_operator = np.empty((0, self._nr_properties),
@@ -971,7 +971,7 @@ def write_to_file(self, filename: str) -> None:
971971
# Write file according to the extension
972972
args = self._prepare_solver_arguments(separate_bounds=True)
973973
if self.verbose > 0:
974-
print("Writing the LP program to", filename)
974+
eprint("Writing the LP program to", filename)
975975
if extension == "lp":
976976
write_to_lp(args, filename)
977977
elif extension == "mps":
@@ -1141,7 +1141,7 @@ def _sanitise_monomial(self, mon: Any) -> CompoundMoment:
11411141
try:
11421142
return self.monomial_from_name[mon]
11431143
except KeyError:
1144-
print(f"As of now we only recognize \n{list(self.monomial_from_name.keys())}")
1144+
eprint(f"As of now we only recognize \n{list(self.monomial_from_name.keys())}")
11451145
return self._sanitise_monomial(self._interpret_name(mon))
11461146
elif isinstance(mon, Real):
11471147
if np.isclose(float(mon), 1):
@@ -1320,7 +1320,7 @@ def _generate_lp(self) -> None:
13201320
orbits_non_CG, return_index=True, return_inverse=True)
13211321
self.num_non_CG = len(old_reps_non_CG)
13221322
if self.verbose > 1:
1323-
print(f"Orbits discovered! {self.num_CG} unique monomials.")
1323+
eprint(f"Orbits discovered! {self.num_CG} unique monomials.")
13241324
# Obtain the real generating monomials after accounting for symmetry
13251325
else:
13261326
self.num_CG = self.raw_n_columns
@@ -1405,7 +1405,7 @@ def _generate_lp(self) -> None:
14051405

14061406
self._lp_has_been_generated = True
14071407
if self.verbose > 1:
1408-
print("LP initialization complete, ready to accept further specifics.")
1408+
eprint("LP initialization complete, ready to accept further specifics.")
14091409

14101410
def _template_to_event_boolarray(self, template: List[int], decompressor: List[np.ndarray]) -> np.ndarray:
14111411
if template:

inflation/sdp/InflationSDP.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,17 @@ def __init__(self,
101101

102102
self.measurements = self._generate_parties()
103103
if self.verbose > 1:
104-
print("Number of single operator measurements per party:", end="")
104+
eprint("Number of single operator measurements per party:", end="")
105105
prefix = " "
106106
for i, measures in enumerate(self.measurements):
107107
counter = count()
108108
deque(zip(chain.from_iterable(
109109
chain.from_iterable(measures)),
110110
counter),
111111
maxlen=0)
112-
print(prefix + f"{self.names[i]}={next(counter)}", end="")
112+
eprint(prefix + f"{self.names[i]}={next(counter)}", end="")
113113
prefix = ", "
114-
print()
114+
eprint()
115115
self.use_lpi_constraints = False
116116
self.network_scenario = inflationproblem.is_network
117117
self._is_knowable_q_non_networks = \
@@ -403,7 +403,7 @@ def generate_relaxation(self,
403403
self.first_free_idx = first_free_index
404404
if self.n_vars < old_num_vars:
405405
if self.verbose > 0:
406-
print("Further variable reduction has been made possible. Number of variables in the SDP:",
406+
eprint("Further variable reduction has been made possible. Number of variables in the SDP:",
407407
self.n_vars)
408408
# self.compmoment_from_idx = dict(zip(range(self.n_vars), monomials_as_list))
409409
# self.compmoment_to_idx = dict(zip(monomials_as_list, range(self.n_vars)))
@@ -1411,7 +1411,7 @@ def write_to_file(self, filename: str) -> None:
14111411

14121412
# Write file according to the extension
14131413
if self.verbose > 0:
1414-
print("Writing the SDP program to", filename)
1414+
eprint("Writing the SDP program to", filename)
14151415
if extension == "dat-s":
14161416
write_to_sdpa(self, filename)
14171417
elif extension == "csv":
@@ -1864,7 +1864,7 @@ def _build_cols_from_specs(self, col_specs: List[List[int]]) -> List:
18641864
for specs in col_specs:
18651865
to_print.append("1" if specs == []
18661866
else "".join([self.names[p] for p in specs]))
1867-
print("Column structure:", "+".join(to_print))
1867+
eprint("Column structure:", "+".join(to_print))
18681868

18691869
_zero_lexorder = np.array([0], dtype=np.intc)
18701870
columns = []
@@ -2082,14 +2082,14 @@ def _cleanup_after_set_values(self) -> None:
20822082
if self.momentmatrix_has_a_one:
20832083
num_nontrivial_known -= 1
20842084
if self.verbose > 1 and num_nontrivial_known > 0:
2085-
print("Number of variables with fixed numeric value:",
2085+
eprint("Number of variables with fixed numeric value:",
20862086
len(self.known_moments))
20872087
if len(self.semiknown_moments):
20882088
for k in self.known_moments.keys():
20892089
self.semiknown_moments.pop(k, None)
20902090
num_semiknown = len(self.semiknown_moments)
20912091
if self.verbose > 1 and num_semiknown > 0:
2092-
print(f"Number of semiknown variables: {num_semiknown}")
2092+
eprint(f"Number of semiknown variables: {num_semiknown}")
20932093

20942094
def _reset_lowerbounds(self) -> None:
20952095
"""Reset the list of lower bounds."""

0 commit comments

Comments
 (0)