From 203150db20d3ef9b0cb2fe54e2b70461ea28ae5b Mon Sep 17 00:00:00 2001 From: vprusso Date: Thu, 3 Oct 2024 18:29:33 -0400 Subject: [PATCH 1/2] Fixing multiplication operator warning for extended nonlocal games. --- toqito/nonlocal_games/extended_nonlocal_game.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/toqito/nonlocal_games/extended_nonlocal_game.py b/toqito/nonlocal_games/extended_nonlocal_game.py index 933edf7e2..d778b62ac 100644 --- a/toqito/nonlocal_games/extended_nonlocal_game.py +++ b/toqito/nonlocal_games/extended_nonlocal_game.py @@ -112,7 +112,7 @@ def unentangled_value(self) -> float: rho = cvxpy.Variable((dim_x, dim_y), hermitian=True) - objective = cvxpy.Maximize(cvxpy.real(cvxpy.trace(p_win.conj().T * rho))) + objective = cvxpy.Maximize(cvxpy.real(cvxpy.trace(p_win.conj().T @ rho))) constraints = [cvxpy.trace(rho) == 1, rho >> 0] problem = cvxpy.Problem(objective, constraints) @@ -194,7 +194,7 @@ def nonsignaling_value(self) -> float: for x_in in range(alice_in): for y_in in range(bob_in): p_win += self.prob_mat[x_in, y_in] * cvxpy.trace( - self.pred_mat[:, :, a_out, b_out, x_in, y_in].conj().T * k_var[a_out, b_out, x_in, y_in] + self.pred_mat[:, :, a_out, b_out, x_in, y_in].conj().T @ k_var[a_out, b_out, x_in, y_in] ) objective = cvxpy.Maximize(cvxpy.real(p_win)) @@ -328,7 +328,7 @@ def __optimize_alice(self, bob_povms) -> tuple[dict, float]: ) .conj() .T - * rho[x_ques, a_ans] + @ rho[x_ques, a_ans] ) if isinstance( bob_povms[y_ques, b_ans], @@ -343,7 +343,7 @@ def __optimize_alice(self, bob_povms) -> tuple[dict, float]: ) .conj() .T - * rho[x_ques, a_ans] + @ rho[x_ques, a_ans] ) objective = cvxpy.Maximize(cvxpy.real(win)) constraints = [] @@ -396,7 +396,7 @@ def __optimize_bob(self, rho) -> tuple[dict, float]: bob_povms[y_ques, b_ans], ) ) - * rho[x_ques, a_ans].value + @ rho[x_ques, a_ans].value ) objective = cvxpy.Maximize(cvxpy.real(win)) @@ -455,7 +455,7 @@ def commuting_measurement_value_upper_bound(self, k: int | str = 1) -> float: for y_in in range(bob_in): p_win += self.prob_mat[x_in, y_in] * cvxpy.trace( self.pred_mat[:, :, a_out, b_out, x_in, y_in].conj().T - * mat[x_in, y_in][ + @ mat[x_in, y_in][ a_out * referee_dim : (a_out + 1) * referee_dim, b_out * referee_dim : (b_out + 1) * referee_dim, ] From 93a2e011b0020b5db26ab19789ab7b8789107517 Mon Sep 17 00:00:00 2001 From: vprusso Date: Thu, 3 Oct 2024 19:59:49 -0400 Subject: [PATCH 2/2] Attempt to fix warning for NLG now. --- toqito/nonlocal_games/nonlocal_game.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/toqito/nonlocal_games/nonlocal_game.py b/toqito/nonlocal_games/nonlocal_game.py index 7e42f0cfd..1f6dcc4f1 100644 --- a/toqito/nonlocal_games/nonlocal_game.py +++ b/toqito/nonlocal_games/nonlocal_game.py @@ -363,7 +363,6 @@ def __optimize_alice(self, dim, bob_povms) -> tuple[dict, float]: # .. math:: # \sum_{(x,y) \in \Sigma} \pi(x, y) V(a,b|x,y) \ip{B_b^y}{A_a^x} win = 0 - is_real = True for x_ques in range(num_inputs_alice): for y_ques in range(num_inputs_bob): for a_ans in range(num_outputs_alice): @@ -372,17 +371,16 @@ def __optimize_alice(self, dim, bob_povms) -> tuple[dict, float]: win += ( self.prob_mat[x_ques, y_ques] * self.pred_mat[a_ans, b_ans, x_ques, y_ques] - * cvxpy.trace(bob_povms[y_ques, b_ans].conj().T * alice_povms[x_ques, a_ans]) + * cvxpy.trace(bob_povms[y_ques, b_ans].conj().T @ alice_povms[x_ques, a_ans]) ) if isinstance( bob_povms[y_ques, b_ans], cvxpy.expressions.variable.Variable, ): - is_real = False win += ( self.prob_mat[x_ques, y_ques] * self.pred_mat[a_ans, b_ans, x_ques, y_ques] - * cvxpy.trace(bob_povms[y_ques, b_ans].value.conj().T * alice_povms[x_ques, a_ans]) + * cvxpy.trace(bob_povms[y_ques, b_ans].value.conj().T @ alice_povms[x_ques, a_ans]) ) objective = cvxpy.Maximize(cvxpy.real(win)) @@ -430,7 +428,7 @@ def __optimize_bob(self, dim, alice_povms) -> tuple[dict, float]: win += ( self.prob_mat[x_ques, y_ques] * self.pred_mat[a_ans, b_ans, x_ques, y_ques] - * cvxpy.trace(bob_povms[y_ques, b_ans].H * alice_povms[x_ques, a_ans].value) + * cvxpy.trace(bob_povms[y_ques, b_ans].H @ alice_povms[x_ques, a_ans].value) ) objective = cvxpy.Maximize(cvxpy.real(win))