Skip to content

Commit

Permalink
all redefinition disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
purva-thakre committed Oct 29, 2023
1 parent b23aa80 commit 95dad08
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions toqito/channels/partial_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def partial_trace(
for idx in sys:
prod_dim_sys *= dim[idx]
elif isinstance(sys, int):
prod_dim_sys = np.prod(dim[sys])
prod_dim_sys = np.prod(dim[sys])# pylint: disable=redefined-variable-type
else:
raise ValueError(
"Invalid: The variable `sys` must either be of type int or of a list of ints."
Expand All @@ -179,7 +179,7 @@ def partial_trace(
sub_sys_vec = prod_dim * np.ones(int(sub_prod)) / sub_prod

if isinstance(sys, list):
sys = np.array(sys)
sys = np.array(sys)# pylint: disable=redefined-variable-type
if isinstance(sys, int):
sys = np.array([sys])
set_diff = list(set(list(range(1, num_sys + 1))) - set(sys + 1))
Expand Down
2 changes: 1 addition & 1 deletion toqito/channels/realignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def realignment(input_mat: np.ndarray, dim: int | list[int] = None) -> np.ndarra
dim = np.array([dim, dim])

dim_x = np.array([[dim[0][1], dim[0][0]], [dim[1][0], dim[1][1]]])
dim_x = np.int_(dim_x)
dim_x = np.int_(dim_x)# pylint: disable=redefined-variable-type
dim_y = np.array([[dim[1][0], dim[0][0]], [dim[0][1], dim[1][1]]])

x_tmp = swap(input_mat, [1, 2], dim, True)
Expand Down
2 changes: 1 addition & 1 deletion toqito/matrices/gell_mann.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ def gell_mann(ind: int, is_sparse: bool = False) -> np.ndarray | scipy.sparse.cs
raise ValueError("Gell-Mann index values can only be values from 0 to 8 (inclusive).")

if is_sparse:
gm_op = scipy.sparse.csr_matrix(gm_op)
gm_op = scipy.sparse.csr_matrix(gm_op)# pylint: disable=redefined-variable-type

return gm_op
2 changes: 1 addition & 1 deletion toqito/matrices/pauli.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def pauli(
pauli_mat = np.identity(2)

if is_sparse:
pauli_mat = sparse.csr_matrix(pauli_mat)
pauli_mat = sparse.csr_matrix(pauli_mat)# pylint: disable=redefined-variable-type

return pauli_mat

Expand Down
2 changes: 1 addition & 1 deletion toqito/matrix_props/is_block_positive.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def is_block_positive(

# Allow the user to enter in a single integer for dimension.
if isinstance(dim, int):
dim = np.array([dim, dim_xy / dim])
dim = np.array([dim, dim_xy / dim])# pylint: disable=redefined-variable-type
if np.abs(dim[1] - np.round(dim[1])) >= 2 * dim_xy * np.finfo(float).eps:
raise ValueError(
"If `dim` is a scalar, it must evenly divide the length of the matrix."
Expand Down
4 changes: 2 additions & 2 deletions toqito/matrix_props/sk_norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def sk_operator_norm( # pylint: disable=too-many-locals

# Allow the user to enter in a single integer for dimension.
if isinstance(dim, int):
dim = np.array([dim, dim_xy / dim])
dim = np.array([dim, dim_xy / dim])# pylint: disable=redefined-variable-type
if np.abs(dim[1] - np.round(dim[1])) >= 2 * dim_xy * np.finfo(float).eps:
raise ValueError(
"If `dim` is a scalar, it must evenly divide the length of the matrix."
Expand Down Expand Up @@ -132,7 +132,7 @@ def sk_operator_norm( # pylint: disable=too-many-locals
# comes from Theorem 4.13 in [1]
lower_bound = k / min(dim)
# our most basic upper bound
upper_bound = 1
upper_bound = 1# pylint: disable=redefined-variable-type

# break out of the function if the target value has already been met
if __target_is_proved(lower_bound, upper_bound, op_norm, tol, target):
Expand Down
2 changes: 1 addition & 1 deletion toqito/nonlocal_games/nonlocal_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def from_bcs_game(cls, constraints: list[np.ndarray], reps: int = 1) -> "Nonloca
bin_a = [int(x) for x in np.binary_repr(a_ans)]
truth_assignment = np.zeros(num_variables, dtype=np.int8)
truth_assignment[-len(bin_a) :] = bin_a
truth_assignment = tuple(truth_assignment)
truth_assignment = tuple(truth_assignment)# pylint: disable=redefined-variable-type

for y_ques in range(num_variables):
# The verifier can only accept the answer if Bob's truth assignment
Expand Down
2 changes: 1 addition & 1 deletion toqito/perms/permute_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def permute_systems(
# If the dimensions are specified, ensure they are given to the
# recursive calls as flattened lists.
if len(dim[0][:]) == 1:
dim = functools.reduce(operator.iconcat, dim, [])
dim = functools.reduce(operator.iconcat, dim, [])# pylint: disable=redefined-variable-type

row_perm = permute_systems(vec_arg, perm, dim[0][:], False, inv_perm)

Expand Down
2 changes: 1 addition & 1 deletion toqito/perms/swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def swap(

# Swap the indicated subsystems.
perm = np.array(range(1, num_sys + 1))
sys = np.array(sys) - 1
sys = np.array(sys) - 1# pylint: disable=redefined-variable-type

perm[sys] = perm[sys[::-1]]

Expand Down
2 changes: 1 addition & 1 deletion toqito/state_opt/optimal_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def optimal_clone(
else:
# The permutation vector `perm` contains elements of the
# sequence from: https://oeis.org/A023123
q_a = tensor(q_a, num_reps)
q_a = tensor(q_a, num_reps)# pylint: disable=redefined-variable-type
perm = []
for i in range(1, num_spaces + 1):
perm.append(i)
Expand Down
4 changes: 2 additions & 2 deletions toqito/state_opt/symmetric_extension_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ def symmetric_extension_hierarchy(

# Allow the user to enter in a single integer for dimension.
if isinstance(dim, int):
dim = np.array([dim, dim_xy / dim])
dim = np.array([dim, dim_xy / dim])# pylint: disable=redefined-variable-type
if np.abs(dim[1] - np.round(dim[1])) >= 2 * dim_xy * np.finfo(float).eps:
raise ValueError("If `dim` is a scalar, it must evenly divide the length of the state.")
dim[1] = int(np.round(dim[1]))

dim_x, dim_y = int(dim[0]), int(dim[1])

dim_list = [dim_x] + [dim_y] * level
dim_list = np.int_(dim_list)
dim_list = np.int_(dim_list)# pylint: disable=redefined-variable-type
# The `sys_list` variable contains the numbering pertaining to the symmetrically extended
# spaces.
sys_list = list(range(2, 2 + level - 1))
Expand Down
4 changes: 2 additions & 2 deletions toqito/state_props/entanglement_of_formation.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def entanglement_of_formation(rho: np.ndarray, dim: list[int] | int = None) -> f
dim = round_dim

# User can specify dimension as integer.
if isinstance(dim, int):
dim = np.array([dim, max(dim_x, dim_y) / dim], dtype=int)
if isinstance(dim, int):
dim = np.array([dim, max(dim_x, dim_y) / dim], dtype=int) # pylint: disable=redefined-variable-type
if abs(dim[1] - np.round(dim[1])) >= 2 * max(dim_x, dim_y) * eps:
raise ValueError(
"Invalid dimension: If `dim` is provided as a "
Expand Down
2 changes: 1 addition & 1 deletion toqito/state_props/has_symmetric_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def has_symmetric_extension(

# Allow the user to enter in a single integer for dimension.
if isinstance(dim, int):
dim = np.array([dim, len_mat / dim])
dim = np.array([dim, len_mat / dim])# pylint: disable=redefined-variable-type
if np.abs(dim[1] - np.round(dim[1])) >= 2 * len_mat * np.finfo(float).eps:
raise ValueError(
"If `dim` is a scalar, it must evenly divide the length of the matrix."
Expand Down
2 changes: 1 addition & 1 deletion toqito/state_props/is_separable.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def is_separable(
dim = int(np.round(np.sqrt(state_len)))

if isinstance(dim, int):
dim = np.array([dim, state_len / dim])
dim = np.array([dim, state_len / dim])# pylint: disable=redefined-variable-type
if np.abs(dim[1] - np.round(dim[1])) >= 2 * state_len * eps:
raise ValueError("The parameter `dim` must evenly divide the length of the state.")
dim[1] = np.round(dim[1])
Expand Down
2 changes: 1 addition & 1 deletion toqito/state_props/schmidt_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def schmidt_rank(rho: np.ndarray, dim: int | list[int] | np.ndarray = None) -> f
if dim is None:
dim = slv
if isinstance(dim, int):
dim = np.array([dim, len(rho) / dim], dtype=int)
dim = np.array([dim, len(rho) / dim], dtype=int)# pylint: disable=redefined-variable-type
dim[1] = np.round(dim[1])

return np.linalg.matrix_rank(np.reshape(rho, dim[::-1]))
Expand Down
2 changes: 1 addition & 1 deletion toqito/state_props/sk_vec_norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def sk_vector_norm(rho: np.ndarray, k: int = 1, dim: int | list[int] = None) ->

# Allow the user to enter in a single integer for dimension.
if isinstance(dim, int):
dim = np.array([dim, dim_xy / dim])
dim = np.array([dim, dim_xy / dim])# pylint: disable=redefined-variable-type
if np.abs(dim[1] - np.round(dim[1])) >= 2 * dim_xy * np.finfo(float).eps:
raise ValueError("If `dim` is a scalar, it must evenly divide the length of the state.")
dim[1] = int(np.round(dim[1]))
Expand Down

0 comments on commit 95dad08

Please sign in to comment.