U
    L?hL                     @   st  d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	m
Z
mZmZmZmZ d dlmZmZmZmZmZmZmZ d dlmZmZ d dlmZ e e e   ZZZed	ed	ed	  ZZZ ed
ed
ed
  Z!Z"Z#e e  Z$Z%ed	ed	 Z&Z'eded Z(Z)dd Z*dd Z+dd Z,dd Z-dd Z.dd Z/dd Z0dd Z1dd Z2dd  Z3d!d" Z4d#d$ Z5d%S )&    )Mul)I)Matrix)latex)Dagger
CommutatorAntiCommutatorqapplyOperator	represent)SigmaOpBaseSigmaXSigmaYSigmaZ
SigmaMinus	SigmaPlusqsimplify_pauli)	SigmaZKet	SigmaZBra)raises      ABc                   C   s|   t ttrt ttstt ttr,t tts0tt ttrDt ttsHtt t	tr\t t	t
s`tt ttrtt ttsxtd S N)
isinstancesxr   r   AssertionErrorsyr   szr   smr   spr    r"   r"   X/var/www/html/venv/lib/python3.8/site-packages/sympy/physics/quantum/tests/test_pauli.pytest_pauli_operators_types   s
    r$   c                   C   s^   t tt dt t kstt tt dt t ks<tt tt dt t ksZtd S Nr   )r   r   r   doitr   r   r   r"   r"   r"   r#   test_pauli_operators_commutator    s    r'   c                   C   s   t tt dt t kstt tt dt t ks<tt tt dt t ksZtt tt dt t	 ksxtt tt	 dt t kstt t	t dt t kstt tt dkstt tt	 dkstt tt dkstd S )Nr   r   )
r   sx1sy1r&   r   sz1r   sx2sy2sz2r"   r"   r"   r#   +test_pauli_operators_commutator_with_labels'   s    r.   c                   C   s\   t tt dkstt tt dks,tt tt dksBtt tt dksXtd S )Nr   r   )r   r   r   r&   r   r   r    r!   r"   r"   r"   r#   #test_pauli_operators_anticommutator6   s    r/   c                   C   s4   t ttkstt ttks tt ttks0td S r   )r   r   r   r   r   r"   r"   r"   r#   test_pauli_operators_adjoint>   s    r0   c                   C   sd   t ttkstt ttks tt ttks0tt ttks@tt ttksPtt ttks`td S r   )r   r(   r   r)   r*   r+   r,   r-   r"   r"   r"   r#   (test_pauli_operators_adjoint_with_labelsE   s    r1   c                   C   s   t tt dkstt tt dks(tt tt dks<tt tt tt ksTtt tt tt ksltt tt tt kstt tt t t kstt tt t t kstt tt t t kstd S Nr   )r   r   r   r   r   r   r"   r"   r"   r#   #test_pauli_operators_multiplicationP   s    r3   c                   C   s   t tt dkstt tt dks(tt tt dks<tttt tsNtttt ts`tttt	 tsrtt tt t t t t	 kstt tt t	 t t t kstd S r2   )
r   r(   r   r)   r*   r   r+   r   r,   r-   r"   r"   r"   r#   /test_pauli_operators_multiplication_with_labels_   s    "r4   c                  C   s4  t  t  } }td}td}t| | |ks2tt| | |ksFtt|| |ksZtt|| | kspttd}td}t||  dd|kstt||  dd|kstt|| dd|kstt|| dd| kstttdtdkstttdtdkstttdd  ttdd  d S )Nr   r   T)daggerc                   S   s   t dS r%   )r   r"   r"   r"   r#   <lambda>       z#test_pauli_states.<locals>.<lambda>c                   S   s   t dS r%   )r   r"   r"   r"   r#   r6      r7   )	r   r   r   r	   r   r   r   r   
ValueError)r   r   upZdownr"   r"   r#   test_pauli_statesm   s"    r:   c                   C   s<   t jdksttjdksttjdks*ttjdks8td S )NFT)r    Zuse_namer   sm1r   r(   r"   r"   r"   r#   test_use_name   s    r<   c                   C   s   t tdkstt tdks tt tdks0tt tdks@tt tdksPtt tdks`tt tdksptt t	dkstt t
d	kstt td
kstd S )Nz
{\sigma_x}z{\sigma_x^{(1)}}z
{\sigma_y}z{\sigma_y^{(1)}}z
{\sigma_z}z{\sigma_z^{(1)}}z
{\sigma_-}z{\sigma_-^{(1)}}z
{\sigma_+}z{\sigma_+^{(1)}})r   r   r   r(   r   r)   r   r*   r    r;   r!   sp1r"   r"   r"   r#   test_printing   s    r>   c                   C   s   t ttddgddggks tt ttdt gtdggksBtt ttddgddggksbtt ttddgddggkstt ttddgddggkstd S )Nr   r   )	r   r   r   r   r   r   r   r    r!   r"   r"   r"   r#   test_represent   s
     "  r@   N)6Zsympy.core.mulr   Zsympy.core.numbersr   Zsympy.matrices.denser   Zsympy.printing.latexr   Zsympy.physics.quantumr   r   r   r	   r
   r   Zsympy.physics.quantum.paulir   r   r   r   r   r   r   r   r   Zsympy.testing.pytestr   r   r   r   r(   r)   r*   r+   r,   r-   r    r!   r;   r=   r   r   r$   r'   r.   r/   r0   r1   r3   r4   r:   r<   r>   r@   r"   r"   r"   r#   <module>   s2    $	