import numpy as np
from qiskit.quantum_info import DensityMatrix, Statevector, purity
qc_state = Statevector.from_label('+')
rho_pure = DensityMatrix(qc_state)
rho_dephased = DensityMatrix(np.eye(2) / 2)
print('Pure state purity:', purity(rho_pure))
print('Fully dephased purity:', purity(rho_dephased))
# Expected: 1.0 and 0.5
