Skip to content

Commit

Permalink
Updating to version 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
vprusso committed Jun 30, 2022
1 parent 90f6210 commit 076592a
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ notes=FIXME,XXX,TODO
[SIMILARITIES]

# Minimum lines number of a similarity.
min-similarity-lines=6
min-similarity-lines=30

# Ignore comments when computing similarities.
ignore-comments=yes
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,8 @@
- Enhancement: Updating `Union` syntax using the `|` operator instead of `Union`
from `typing`.

- Enhancement: Linting and stylistic improvements.
- Enhancement: Linting and stylistic improvements.

## 1.0.3

-
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
author = "Vincent Russo"

# The full version, including alpha/beta/rc tags
release = "1.0.1"
release = "1.0.2"


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exclude = '''

[tool.poetry]
name = "toqito"
version = "1.0.1"
version = "1.0.2"
description = "Python tools for the study of quantum information."
authors = [
"Vincent Russo <vincentrusso1@gmail.com>"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name="toqito",
version="1.0.1",
version="1.0.2",
author="Vincent Russo",
author_email="vincentrusso1@gmail.com",
description="Python toolkit for quantum information theory",
Expand Down
14 changes: 7 additions & 7 deletions tests/test_state_props/test_is_separable.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def test_entangled_realignment_criterion():

def test_entangled_cross_norm_realignment_criterion():
"""Determined to be entangled by using Theorem 1 and Remark 1 of Quantum Inf. Comput., 3:193-202, 2003."""
create_rho = lambda p,a,b: np.array(
p_var, a_var, b_var = 0.4, 0.8, 0.64
rho = np.array(
[
[p * a ** 2, 0, 0, p * a * b],
[0, (1 - p) * a ** 2, (1 - p) * a * b, 0],
[0, (1 - p) * a * b, (1 - p) * a ** 2, 0],
[p * a * b, 0, 0, p * a ** 2],
[p_var * a_var ** 2, 0, 0, p_var * a_var * b_var],
[0, (1 - p_var) * a_var ** 2, (1 - p_var) * a_var * b_var, 0],
[0, (1 - p_var) * a_var * b_var, (1 - p_var) * a_var ** 2, 0],
[p_var * a_var * b_var, 0, 0, p_var * a_var ** 2],
]
)
rho = create_rho(0.4, 0.8, 0.64)
)
np.testing.assert_equal(is_separable(rho), False)


Expand Down
1 change: 1 addition & 0 deletions toqito/nonlocal_games/nonlocal_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def from_bcs_game(cls, constraints: list[np.ndarray], reps: int = 1) -> "Nonloca
"""
Construct nonlocal game object from a binary constraint system game.
:raises ValueError: At least one constraint needs to be supplied.
:param constraints: A list of m matrices corresponding to the `m`
constraints in the BCS game. Each constraint matrix is
an `n`-dimensional matrix of shape `2 x 2 x ... x 2`.
Expand Down
3 changes: 3 additions & 0 deletions toqito/nonlocal_games/xor_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def __init__(
"""
Construct XOR game object.
:raises ValueError: If dimension of probability matrix is not equal to
dimension of predicate matrix.
:param prob_mat: A matrix whose (q_0, q_1)-entry gives the probability that
the referee will give Alice the value `q_0` and Bob the
value `q_1`.
Expand Down Expand Up @@ -241,6 +243,7 @@ def classical_value(self) -> float:
"""
Compute the classical value of the XOR game.
:raises ValueError: Does not support parallel repetitions.
:return: A value between [0, 1] representing the classical value.
"""
if self.reps == 1:
Expand Down
3 changes: 2 additions & 1 deletion toqito/state_ops/pure_to_mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def pure_to_mixed(phi: np.ndarray) -> np.ndarray:
[0. , 0. , 0. , 0. ],
[0.5, 0. , 0. , 0.5]])
:raises ValueError: If matrix is not square.
:param phi: A density matrix or a pure state vector.
:return: density matrix representation of :code:`phi`, regardless of whether :code:`phi` is
itself already a density matrix or if if is a pure state vector.
Expand All @@ -62,4 +63,4 @@ def pure_to_mixed(phi: np.ndarray) -> np.ndarray:
if row_dim == col_dim:
return phi
# It's neither.
raise ValueError("InvalidDim: `phi` must be either a vector or square " "matrix.")
raise ValueError("InvalidDim: `phi` must be either a vector or square matrix.")
4 changes: 4 additions & 0 deletions toqito/state_ops/schmidt_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def schmidt_decomposition(
==========
.. [WikSD] Wikipedia: Schmidt decomposition
https://en.wikipedia.org/wiki/Schmidt_decomposition
:raises ValueError: If matrices are not of equal dimension.
:param rho: A bipartite quantum state to compute the Schmidt decomposition of.
:param dim: An array consisting of the dimensions of the subsystems (default gives subsystems
equal dimensions).
Expand Down Expand Up @@ -120,8 +122,10 @@ def _operator_schmidt_decomposition(
Given an input `rho` provided as a matrix, determine its corresponding
Schmidt decomposition.
:raises ValueError: If matrices are not of equal dimension..
:param rho: The matrix.
:param dim: The dimension of the matrix
:param k_param: The number of Schmidt coefficients to compute.
:return: The Schmidt decomposition of the :code:`rho` input.
"""
eps = np.finfo(float).eps
Expand Down
5 changes: 3 additions & 2 deletions toqito/state_opt/ppt_distinguishability.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
def ppt_distinguishability(
states: list[np.ndarray],
probs: list[float] = None,
dist_method="min-error",
strategy=False,
dist_method: str = "min-error",
strategy: bool = False,
) -> float:
r"""
Compute probability of optimally distinguishing a state via PPT measurements [COS13]_.
Expand Down Expand Up @@ -98,6 +98,7 @@ def ppt_distinguishability(
https://arxiv.org/abs/1107.3224
:param states: A list of states provided as either matrices or vectors.
:param dist_method: The method of distinguishing states.
:param probs: Respective list of probabilities each state is selected.
:param dist_method: Method of distinguishing to use.
:param strategy: Returns strategy if :code:`True` and does not otherwise.
Expand Down
2 changes: 1 addition & 1 deletion toqito/state_props/entanglement_of_formation.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ def entanglement_of_formation(rho: np.ndarray, dim: list[int] | int = None) -> f
"the entanglement-of-formation for two-qubit states and pure "
"states."
)
raise ValueError("Invalid dimension: `rho` must be either a vector or " "square matrix.")
raise ValueError("Invalid dimension: `rho` must be either a vector or square matrix.")
2 changes: 1 addition & 1 deletion toqito/state_props/von_neumann_entropy.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def von_neumann_entropy(rho: np.ndarray) -> float:
:return: The von Neumann entropy of :code:`rho`.
"""
if not is_density(rho):
raise ValueError("Von Neumann entropy is only defined for density " "operators.")
raise ValueError("Von Neumann entropy is only defined for density operators.")
eigs, _ = np.linalg.eig(rho)
eigs = [eig for eig in eigs if eig > 0]
return -np.sum(np.real(eigs * np.log2(eigs)))

0 comments on commit 076592a

Please sign in to comment.