Skip to main content

Python toolkit for quantum information theory

Project description

ToQITo (Theory of Quantum Information Toolkit)

The toqito package is a Python package for studying various aspects of quantum information theory. Specifically, toqito focuses on providing numerical tools to study problems pertaining to entanglement theory, nonlocal games, matrix analysis, and other aspects of quantum information that are often associated with computer science.

build status Coverage Status DOI Code style: black Unitary Fund

toqito aims to fill the needs of quantum information researchers who want numerical and computational tools for manipulating quantum states, measurements, and channels. It can also be used as a tool to enhance the experience of students and instructors in classes pertaining to quantum information.

The inspiration for this package is heavily influenced by the QETLAB package in MATLAB by Nathaniel Johnston. Many of the functions found here are direct ports of those functions converted into Python code.

Citing toqito

You can cite toqito using the following DOI: 10.5281/zenodo.3699578

If you are using the toqito software package in research work, please include an explicit mention of toqito in your publication. Something along the lines of:

To solve problem "X" we used `toqito`; a package for studying certain
aspects of quantum information.

A BibTeX entry that you can use to cite toqito is provided here:

   author       = {Vincent Russo},
   title        = {toqito: A {P}ython toolkit for quantum information, version 0.1},
   howpublished = {\url{}},
   month        = Mar,
   year         = 2020,
   doi          = {10.5281/zenodo.3699578}


All of the examples can be found in the form of Python Jupyter notebook tutorials


The following lists the current functionality of toqito. Each bullet item currently links to or will link to a Jupyter notebook file that showcases the usage.

Filling in the jupyter notebook example files lags behind the features presently offered in toqito and will be periodically updated as time allows.


Calculate various quantities of interest pertaining to entanglement.

  • concurrence: Computes the concurrence for a bipartite system.
  • negativity: Computes the negativity of a bipartite density matrix.



  • clock: Generates the clock matrix.
  • fourier: Generate unitary matrix that implements the quantum Fourier transform.
  • gell_mann: Produces a Gell-Mann operator.
  • gen_gell_man: Produces a generalized Gell-Mann operator.
  • gen_pauli: Produces a generalized Pauli operator (sometimes called a Weyl operator).
  • iden: Computes a sparse or full identity matrix.
  • pauli: Produces a Pauli operator.
  • shift: Generates the shift matrix.


  • tensor: Kronecker tensor product of two or more matrices.
  • vec: Computes the vec representation of a given matrix.


  • is_density: Determines whether or not a matrix is a density matrix.
  • is_diagonal: Determines whether or not a matrix is diagonal.
  • is_hermitian: Determines whether or not a matrix is Hermitian.
  • is_normal: Determines whether or not a matrix is normal.
  • is_pd: Determines whether or not a matrix is positive definite.
  • is_projection: Determines whether or not a matrix is a projection matrix.
  • is_psd: Determines whether or not a matrix is positive semidefinite.
  • is_square: Determines whether or not a matrix is square.
  • is_symmetric: Determines whether or not a matrix is symmetric.
  • is_unitary: Determines whether or not a matrix is unitary.


  • is_povm: Determines if a set of matrices are valid measurements operators.

Nonlocal games

  • two_player_quantum_lower_bound: Computes a lower bound on the quantum value of a nonlocal game.

Bit commitment

Coin flipping

  • weak_coin_flipping: Weak coin flipping protocol.

Die rolling

Extended nonlocal games


  • hedging_value: Semidefinite programs for obtaining values of quantum hedging scenarios.

XOR games

  • xor_game_value: Compute the classical or quantum value of a two-player nonlocal XOR game.


  • antisymmetric_projection: Produces the projection onto the antisymmetric subspace.
  • perfect_matchings: Gives all perfect matchings of N objects.
  • perm_sign: Computes the sign of a permutation.
  • permutation_operator: Produces a unitary operator that permutes subsystems.
  • permute_systems: Permutes subsystems within a state or operator.
  • swap: Swaps two subsystems within a state or operator.
  • swap_operator: Produces a unitary operator that swaps two subsystems.
  • symmetric_projection: Produces the projection onto the symmetric subspace.
  • unique_perms: Compute all distinct permutations of a given vector.


  • random_density_matrix: Generates a random density matrix.
  • random_povm: Generate a random set of positive-operator-valued measurements (POVMs).
  • random_state_vector: Generates a random pure state vector.
  • random_unitary: Generates a random unitary or orthogonal matrix.



  • bures_distance: Computes the Bures distance of two density matrices.
  • bures_metric: Computes the Bures metric between two density matrices.
  • entropy: Computes the von Neumann or Rényi entropy of a density matrix.
  • fidelity: Computes the fidelity of two density matrices.
  • helstrom_holevo: Computes the Helstrom-Holevo distance between two density matrices.
  • purity: Computes the purity of a quantum state.
  • super_fidelity: Computes the super-fidelity of two density matrices.
  • trace_distance: Computes the trace distance of two matrices.
  • trace_norm: Computes the trace norm of a matrix.


  • pure_to_mixed: Converts a state vector or density matrix to a density matrix.
  • schmidt_decomposition: Computes the Schmidt decomposition of a bipartite vector.
  • schmidt_rank: Computes the Schmidt rank of a bipartite vector.


  • conclusive_state_exclusion: Calculates probability of conclusive single state exclusion.
  • ppt_distinguishability: Calculates probability of distinguishing via PPT measurements.
  • state_cloning: Calculate the optimal probability of cloning a quantum state.
  • state_discrimination: Calculates probability of state discrimination.
  • state_distance: Distinguish a set of quantum states.
  • unambiguous_state_exclusion: Calculates probability of unambiguous state exclusion.


  • is_mixed: Determines if state is mixed.
  • is_mutually_unbiased_basis: Check if list of vectors constitute a mutually unbiased basis.
  • is_ppt: Determines whether or not a matrix has positive partial transpose.
  • is_product_vector: Determines if a pure state is a product vector.
  • is_pure: Determines if a state is pure or a list of states are pure.
  • is_quantum_latin_square: Check if list of vectors constitute a quantum Latin square.


  • bell: Produces a Bell state.
  • chessboard: Produces a chessboard state.
  • domino: Produces a Domino state.
  • gen_bell: Produces a generalized Bell state.
  • ghz: Generates a (generalized) GHZ state.
  • gisin: Generates a 2-qubit Gisin state.
  • horodecki: Produces a Horodecki_state.
  • isotropic: Produces an isotropic state.
  • max_entangled: Produces a maximally entangled bipartite pure state.
  • max_mixed: Produces the maximally mixed state.
  • w_state: Generates a (generalized) W-state.
  • werner: Produces a Werner state.

Super operators

  • apply_map: Applies a superoperator to an operator.
  • choi_map: Produces the Choi map or one of its generalizations.
  • dephasing_channel: Produces a dephasing channel.
  • depolarizing_channel: Produces a depolarizng channel.
  • partial_trace: Computes the partial trace of a matrix.
  • partial_transpose: Computes the partial transpose of a matrix.
  • realignment: Computes the realignment of a bipartite operator.
  • reduction_map: Produces the reduction map.


The nose module is used for testing. To run the suite of tests for toqito, run the following command in the root directory of this project.

nosetests --with-coverage --cover-erase --cover-package toqito


MIT License

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for toqito, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size toqito-0.0.1-py2.py3-none-any.whl (131.9 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size toqito-0.0.1.tar.gz (65.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page