<s> from sympy import Symbol , Integer <EOL> from sympy . physics . quantum . qexpr import QExpr , _qsympify_sequence <EOL> from sympy . physics . quantum . hilbert import HilbertSpace <EOL> from sympy . core . containers import Tuple <EOL> x = Symbol ( '<STR_LIT:x>' ) <EOL> y = Symbol ( '<STR_LIT:y>' ) <EOL> def test_qexpr_new ( ) : <EOL> q = QExpr ( <NUM_LIT:0> ) <EOL> assert q . label == ( <NUM_LIT:0> , ) <EOL> assert q . hilbert_space == HilbertSpace ( ) <EOL> assert q . is_commutative is False <EOL> q = QExpr ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> assert q . label == ( Integer ( <NUM_LIT:0> ) , Integer ( <NUM_LIT:1> ) ) <EOL> q = QExpr . _new_rawargs ( HilbertSpace ( ) , Integer ( <NUM_LIT:0> ) , Integer ( <NUM_LIT:1> ) ) <EOL> assert q . label == ( Integer ( <NUM_LIT:0> ) , Integer ( <NUM_LIT:1> ) ) <EOL> assert q . hilbert_space == HilbertSpace ( ) <EOL> def test_qexpr_commutative ( ) : <EOL> q1 = QExpr ( x ) <EOL> q2 = QExpr ( y ) <EOL> assert q1 . is_commutative is False <EOL> assert q2 . is_commutative is False <EOL> assert q1 * q2 != q2 * q1 <EOL> q = QExpr . _new_rawargs ( <NUM_LIT:0> , <NUM_LIT:1> , HilbertSpace ( ) ) <EOL> assert q . is_commutative is False <EOL> def test_qexpr_commutative_free_symbols ( ) : <EOL> q1 = QExpr ( x ) <EOL> assert q1 . free_symbols . pop ( ) . is_commutative is False <EOL> q2 = QExpr ( '<STR_LIT>' ) <EOL> assert q2 . free_symbols . pop ( ) . is_commutative is False <EOL> def test_qexpr_subs ( ) : <EOL> q1 = QExpr ( x , y ) <EOL> assert q1 . subs ( x , y ) == QExpr ( y , y ) <EOL> assert q1 . subs ( { x : <NUM_LIT:1> , y : <NUM_LIT:2> } ) == QExpr ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> def test_qsympify ( ) : <EOL> assert _qsympify_sequence ( [ [ <NUM_LIT:1> , <NUM_LIT:2> ] , [ <NUM_LIT:1> , <NUM_LIT:3> ] ] ) == ( Tuple ( <NUM_LIT:1> , <NUM_LIT:2> ) , Tuple ( <NUM_LIT:1> , <NUM_LIT:3> ) ) <EOL> assert _qsympify_sequence ( ( [ <NUM_LIT:1> , <NUM_LIT:2> , [ <NUM_LIT:3> , <NUM_LIT:4> , [ <NUM_LIT:2> , ] ] , <NUM_LIT:1> ] , <NUM_LIT:3> ) ) == ( Tuple ( <NUM_LIT:1> , <NUM_LIT:2> , Tuple ( <NUM_LIT:3> , <NUM_LIT:4> , Tuple ( <NUM_LIT:2> , ) ) , <NUM_LIT:1> ) , <NUM_LIT:3> ) <EOL> assert _qsympify_sequence ( ( <NUM_LIT:1> , ) ) == ( <NUM_LIT:1> , ) </s>
