Skip to content

Commit

Permalink
state_props:eof
Browse files Browse the repository at this point in the history
  • Loading branch information
purva-thakre committed Oct 23, 2023
1 parent 1638697 commit b1d28c6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions toqito/state_props/entanglement_of_formation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Computes the entanglement of formation of a bipartite quantum state."""

from __future__ import annotations

import numpy as np
import scipy
Expand Down Expand Up @@ -65,7 +66,7 @@ def entanglement_of_formation(rho: np.ndarray, dim: list[int] | int = None) -> f

# User can specify dimension as integer.
if isinstance(dim, int):
dim = np.array([dim, max(dim_x, dim_y) / dim], dtype=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 All @@ -87,7 +88,7 @@ def entanglement_of_formation(rho: np.ndarray, dim: list[int] | int = None) -> f
# Start computing entanglement-of-formation.
if min(dim_x, dim_y) == 1:
rho = rho[:]
dim = [x for x in dim]
dim = [int(x) for x in dim]
return von_neumann_entropy(partial_trace(rho * rho.conj().T, [1], dim))

# Case: :code:`rho` is a density matrix.
Expand Down

0 comments on commit b1d28c6

Please sign in to comment.