Skip to content

Commit

Permalink
fixing renaming error
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomello committed Nov 12, 2024
1 parent 194c357 commit e4333d2
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/qibo/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def apply(self, backend, state):
return norm

def apply_density_matrix(self, backend, state):
norm = backend.calculate_matrix_norm_density_matrix(state)
norm = backend.calculate_matrix_norm(state)
self.append(norm)
return norm

Expand Down
4 changes: 2 additions & 2 deletions src/qibo/quantum_info/entropies.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ def renyi_entropy(state, alpha: Union[float, int], base: float = 2, backend=None
return (
-1
* backend.np.log2(
backend.calculate_matrix_norm_density_matrix(state, order=2)
backend.calculate_matrix_norm(state, order=2)
)
/ np.log2(base)
)
Expand Down Expand Up @@ -892,7 +892,7 @@ def relative_renyi_entropy(
new_target = matrix_power(target, 0.5, backend=backend)

log = backend.np.log2(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
new_state @ new_target, order=1
)
)
Expand Down
6 changes: 3 additions & 3 deletions src/qibo/quantum_info/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def trace_distance(state, target, check_hermitian: bool = False, backend=None):
if check_hermitian is True:
hermitian = bool(
float(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
backend.np.transpose(backend.np.conj(difference), (1, 0))
- difference,
order=2,
Expand Down Expand Up @@ -440,7 +440,7 @@ def process_fidelity(channel, target=None, check_unitary: bool = False, backend=

if check_unitary is True:
norm_channel = float(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
backend.np.matmul(
backend.np.conj(backend.np.transpose(channel, (1, 0))), channel
)
Expand Down Expand Up @@ -929,7 +929,7 @@ def _check_hermitian(matrix, backend=None):
"""
backend = _check_backend(backend)

norm = backend.calculate_matrix_norm_density_matrix(
norm = backend.calculate_matrix_norm(
backend.np.conj(matrix).T - matrix, order=2
)

Expand Down
2 changes: 1 addition & 1 deletion src/qibo/quantum_info/quantum_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def is_hermitian(
adjoint = self._backend.np.transpose(reshaped)

mat_diff = self._backend.np.conj(adjoint) - reshaped
norm = self._backend.calculate_matrix_norm_density_matrix(mat_diff, order=order)
norm = self._backend.calculate_matrix_norm(mat_diff, order=order)

return float(norm) <= precision_tol

Expand Down
4 changes: 2 additions & 2 deletions src/qibo/quantum_info/superoperator_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def choi_to_kraus(

if validate_cp:
norm = float(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
choi_super_op - backend.np.conj(choi_super_op).T, order=2
)
)
Expand Down Expand Up @@ -2133,7 +2133,7 @@ def function(x0, operators):
operator = operator + prob * oper

return float(
backend.calculate_matrix_norm_density_matrix(target - operator, order=2)
backend.calculate_matrix_norm(target - operator, order=2)
)

# initial parameters as flat distribution
Expand Down
2 changes: 1 addition & 1 deletion src/qibo/transpiler/unitary_decompositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def calculate_single_qubit_unitaries(psi, backend=None):
psi_magic = backend.np.matmul(backend.np.conj(backend.cast(magic_basis)).T, psi)
if (
backend.np.real(
backend.calculate_matrix_norm_density_matrix(backend.np.imag(psi_magic))
backend.calculate_matrix_norm(backend.np.imag(psi_magic))
)
> 1e-6
): # pragma: no cover
Expand Down
8 changes: 4 additions & 4 deletions tests/test_gates_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_kraus_channel(backend, pauli_order):

backend.assert_allclose(
float(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
channel.to_liouville(backend=backend) - test_superop, order=2
)
)
Expand All @@ -117,7 +117,7 @@ def test_kraus_channel(backend, pauli_order):
)
backend.assert_allclose(
float(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
channel.to_choi(backend=backend) - test_choi, order=2
)
)
Expand Down Expand Up @@ -240,7 +240,7 @@ def test_pauli_noise_channel(backend, pauli_order):
normalize=True, pauli_order=pauli_order, backend=backend
)
norm = float(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
backend.to_numpy(liouville) - test_representation, order=2
)
)
Expand Down Expand Up @@ -384,7 +384,7 @@ def test_thermal_relaxation_channel(backend, t_1, t_2, time, excpop):

backend.assert_allclose(
float(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
final_state - target_state, order=2
)
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_quantum_info_entropies.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def test_renyi_entropy(backend, alpha, base):
elif alpha == 1.0:
target = von_neumann_entropy(state, base=base, backend=backend)
elif alpha == np.inf:
target = backend.calculate_matrix_norm_density_matrix(state, order=2)
target = backend.calculate_matrix_norm(state, order=2)
target = -1 * backend.np.log2(target) / np.log2(base)
else:
target = np.log2(
Expand Down Expand Up @@ -687,7 +687,7 @@ def test_relative_renyi_entropy(backend, alpha, base, state_flag, target_flag):
new_target = matrix_power(target_outer, 0.5, backend=backend)

log = backend.np.log2(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
new_state @ new_target, order=1
)
)
Expand Down
20 changes: 10 additions & 10 deletions tests/test_quantum_info_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_random_hermitian(backend):
matrix = random_hermitian(dims, backend=backend)
matrix_dagger = backend.np.conj(matrix).T
norm = float(
backend.calculate_matrix_norm_density_matrix(matrix - matrix_dagger, order=2)
backend.calculate_matrix_norm(matrix - matrix_dagger, order=2)
)
backend.assert_allclose(norm < PRECISION_TOL, True)

Expand All @@ -122,7 +122,7 @@ def test_random_hermitian(backend):
matrix = random_hermitian(dims, semidefinite=True, backend=backend)
matrix_dagger = backend.np.conj(matrix).T
norm = float(
backend.calculate_matrix_norm_density_matrix(matrix - matrix_dagger, order=2)
backend.calculate_matrix_norm(matrix - matrix_dagger, order=2)
)
backend.assert_allclose(norm < PRECISION_TOL, True)

Expand All @@ -135,7 +135,7 @@ def test_random_hermitian(backend):
matrix = random_hermitian(dims, normalize=True, backend=backend)
matrix_dagger = backend.np.conj(matrix).T
norm = float(
backend.calculate_matrix_norm_density_matrix(matrix - matrix_dagger, order=2)
backend.calculate_matrix_norm(matrix - matrix_dagger, order=2)
)
backend.assert_allclose(norm < PRECISION_TOL, True)

Expand Down Expand Up @@ -184,7 +184,7 @@ def test_random_unitary(backend, measure):
else np.linalg.inv(matrix)
)
norm = float(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
matrix_inv - matrix_dagger, order=2
)
)
Expand Down Expand Up @@ -283,7 +283,7 @@ def test_random_density_matrix(backend, dims, pure, metric, basis, normalize):
test = random_density_matrix(dims=dims, normalize=True)
else:
norm_function = (
backend.calculate_matrix_norm_density_matrix
backend.calculate_matrix_norm
if basis is None
else backend.calculate_norm
)
Expand Down Expand Up @@ -424,7 +424,7 @@ def test_pauli_single(backend):
backend.assert_allclose(
np.abs(
backend.to_numpy(
backend.calculate_matrix_norm_density_matrix(matrix - result, order=2)
backend.calculate_matrix_norm(matrix - result, order=2)
)
)
< PRECISION_TOL,
Expand Down Expand Up @@ -465,7 +465,7 @@ def test_random_pauli(
if subset is None:
backend.assert_allclose(
float(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
matrix - result_complete_set, order=2
)
)
Expand All @@ -475,7 +475,7 @@ def test_random_pauli(
else:
backend.assert_allclose(
float(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
matrix - result_subset, order=2
)
)
Expand All @@ -490,7 +490,7 @@ def test_random_pauli(
if subset is None:
backend.assert_allclose(
float(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
matrix - result_complete_set, order=2
)
)
Expand All @@ -500,7 +500,7 @@ def test_random_pauli(
else:
backend.assert_allclose(
float(
backend.calculate_matrix_norm_density_matrix(
backend.calculate_matrix_norm(
matrix - result_subset, order=2
)
)
Expand Down

0 comments on commit e4333d2

Please sign in to comment.