Coverage for docs/source/examples/sub_multi_values.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

7 statements  

1"Example substitution; adapted from t_sub.py/t_NomialSubs/test_Vector" 

2from gpkit import Variable, VectorVariable 

3x = Variable("x") 

4y = Variable("y") 

5z = VectorVariable(2, "z") 

6p = x*y*z 

7assert all(p.sub({x: 1, "y": 2}) == 2*z) 

8assert all(p.sub({x: 1, y: 2, "z": [1, 2]}) == z.sub({z: [2, 4]}))