@@ -344,14 +344,14 @@ class ThresholdMethodBase(object):
344
344
345
345
def test_product (self ):
346
346
circuit = ('Gx' , 'Gy' )
347
- p1 = np . dot ( self .model ['Gy' ].to_dense (), self .model ['Gx' ].to_dense () )
347
+ p1 = self .model ['Gy' ].to_dense () @ self .model ['Gx' ].to_dense ()
348
348
p2 = self .model .sim .product (circuit , scale = False )
349
349
p3 , scale = self .model .sim .product (circuit , scale = True )
350
350
self .assertArraysAlmostEqual (p1 , p2 )
351
351
self .assertArraysAlmostEqual (p1 , scale * p3 )
352
352
353
353
circuit = ('Gx' , 'Gy' , 'Gy' )
354
- p1 = np . dot ( self .model ['Gy' ].to_dense (), np . dot ( self .model ['Gy' ].to_dense (), self .model ['Gx' ].to_dense ()) )
354
+ p1 = self .model ['Gy' ].to_dense () @ self .model ['Gy' ].to_dense () @ self .model ['Gx' ].to_dense ()
355
355
p2 = self .model .sim .product (circuit , scale = False )
356
356
p3 , scale = self .model .sim .product (circuit , scale = True )
357
357
self .assertArraysAlmostEqual (p1 , p2 )
@@ -362,8 +362,8 @@ def test_bulk_product(self):
362
362
gatestring2 = ('Gx' , 'Gy' , 'Gy' )
363
363
circuits = [gatestring1 , gatestring2 ]
364
364
365
- p1 = np . dot ( self .model ['Gy' ].to_dense (), self .model ['Gx' ].to_dense () )
366
- p2 = np . dot ( self .model ['Gy' ].to_dense (), np . dot ( self .model ['Gy' ].to_dense (), self .model ['Gx' ].to_dense ()) )
365
+ p1 = self .model ['Gy' ].to_dense () @ self .model ['Gx' ].to_dense ()
366
+ p2 = self .model ['Gy' ].to_dense () @ self .model ['Gy' ].to_dense () @ self .model ['Gx' ].to_dense ()
367
367
368
368
bulk_prods = self .model .sim .bulk_product (circuits )
369
369
bulk_prods_scaled , scaleVals = self .model .sim .bulk_product (circuits , scale = True )
@@ -405,15 +405,15 @@ def setUpClass(cls):
405
405
cls .gatestring1 = ('Gx' , 'Gy' )
406
406
cls .gatestring2 = ('Gx' , 'Gy' , 'Gy' )
407
407
cls ._expected_probs = {
408
- cls .gatestring1 : np .dot ( np . transpose (cls ._model .povms ['Mdefault' ]['0' ].to_dense ()),
409
- np . dot ( cls ._model ['Gy' ].to_dense (),
410
- np . dot ( cls ._model ['Gx' ].to_dense (),
411
- cls ._model .preps ['rho0' ].to_dense ()))) .reshape (- 1 )[0 ],
412
- cls .gatestring2 : np .dot ( np . transpose (cls ._model .povms ['Mdefault' ]['0' ].to_dense ()),
413
- np . dot ( cls ._model ['Gy' ].to_dense (),
414
- np . dot ( cls ._model ['Gy' ].to_dense (),
415
- np . dot ( cls ._model ['Gx' ].to_dense (),
416
- cls ._model .preps ['rho0' ].to_dense ())))) .reshape (- 1 )[0 ]
408
+ cls .gatestring1 : np .transpose (cls ._model .povms ['Mdefault' ]['0' ].to_dense ()) @
409
+ cls ._model ['Gy' ].to_dense () @
410
+ cls ._model ['Gx' ].to_dense () @
411
+ cls ._model .preps ['rho0' ].to_dense ().reshape (- 1 )[0 ],
412
+ cls .gatestring2 : np .transpose (cls ._model .povms ['Mdefault' ]['0' ].to_dense ()) @
413
+ cls ._model ['Gy' ].to_dense () @
414
+ cls ._model ['Gy' ].to_dense () @
415
+ cls ._model ['Gx' ].to_dense () @
416
+ cls ._model .preps ['rho0' ].to_dense ().reshape (- 1 )[0 ]
417
417
}
418
418
# TODO expected dprobs & hprobs
419
419
@@ -611,12 +611,12 @@ def test_transform(self):
611
611
612
612
# TODO is this needed?
613
613
for opLabel in cp .operations :
614
- self .assertArraysAlmostEqual (cp [opLabel ], np . dot ( Tinv , np . dot ( self .model [opLabel ], T )) )
614
+ self .assertArraysAlmostEqual (cp [opLabel ], Tinv @ self .model [opLabel ] @ T )
615
615
for prepLabel in cp .preps :
616
- self .assertArraysAlmostEqual (cp [prepLabel ], np . dot ( Tinv , self .model [prepLabel ]) )
616
+ self .assertArraysAlmostEqual (cp [prepLabel ], Tinv @ self .model [prepLabel ])
617
617
for povmLabel in cp .povms :
618
618
for effectLabel , eVec in cp .povms [povmLabel ].items ():
619
- self .assertArraysAlmostEqual (eVec , np .dot ( np . transpose (T ), self .model .povms [povmLabel ][effectLabel ]) )
619
+ self .assertArraysAlmostEqual (eVec , np .transpose (T ) @ self .model .povms [povmLabel ][effectLabel ])
620
620
621
621
def test_gpindices (self ):
622
622
# Test instrument construction with elements whose gpindices
0 commit comments