@@ -453,28 +453,31 @@ def test_oper_equiv(self):
453
453
454
454
result = util .oper_equiv (psi , psi * np .exp (1j * phase ))
455
455
self .assertTrue (result [0 ])
456
- self .assertAlmostEqual (result [1 ], phase , places = 5 )
456
+ self .assertAlmostEqual (np . mod ( result [1 ], 2 * np . pi ), np . mod ( phase , 2 * np . pi ) , places = 5 )
457
457
458
458
result = util .oper_equiv (psi * np .exp (1j * phase ), psi )
459
459
self .assertTrue (result [0 ])
460
- self .assertAlmostEqual (result [1 ], - phase , places = 5 )
460
+ self .assertAlmostEqual (np . mod ( result [1 ], 2 * np . pi ), np . mod ( - phase , 2 * np . pi ) , places = 5 )
461
461
462
462
psi /= np .linalg .norm (psi , ord = 2 )
463
463
464
464
result = util .oper_equiv (psi , psi * np .exp (1j * phase ), normalized = True , eps = 1e-13 )
465
465
self .assertTrue (result [0 ])
466
- self .assertArrayAlmostEqual (result [1 ], phase , atol = 1e-5 )
466
+ self .assertArrayAlmostEqual (np .mod (result [1 ], 2 * np .pi ), np .mod (phase , 2 * np .pi ),
467
+ atol = 1e-5 )
467
468
468
469
result = util .oper_equiv (psi , psi + 1 )
469
470
self .assertFalse (result [0 ])
470
471
471
472
result = util .oper_equiv (U , U * np .exp (1j * phase ))
472
473
self .assertTrue (np .all (result [0 ]))
473
- self .assertArrayAlmostEqual (result [1 ], phase , atol = 1e-5 )
474
+ self .assertArrayAlmostEqual (np .mod (result [1 ], 2 * np .pi ), np .mod (phase , 2 * np .pi ),
475
+ atol = 1e-5 )
474
476
475
477
result = util .oper_equiv (U * np .exp (1j * phase ), U )
476
478
self .assertTrue (np .all (result [0 ]))
477
- self .assertArrayAlmostEqual (result [1 ], - phase , atol = 1e-5 )
479
+ self .assertArrayAlmostEqual (np .mod (result [1 ], 2 * np .pi ), np .mod (- phase , 2 * np .pi ),
480
+ atol = 1e-5 )
478
481
479
482
norm = np .sqrt (util .dot_HS (U , U ))
480
483
norm = norm [:, None , None ] if U .ndim == 3 else norm
@@ -483,7 +486,7 @@ def test_oper_equiv(self):
483
486
# U /= np.expand_dims(np.sqrt(util.dot_HS(U, U)), axis=(-1, -2))
484
487
result = util .oper_equiv (U , U * np .exp (1j * phase ), normalized = True , eps = 1e-10 )
485
488
self .assertTrue (np .all (result [0 ]))
486
- self .assertArrayAlmostEqual (result [1 ], phase )
489
+ self .assertArrayAlmostEqual (np . mod ( result [1 ], 2 * np . pi ), np . mod ( phase , 2 * np . pi ) )
487
490
488
491
result = util .oper_equiv (U , U + 1 )
489
492
self .assertFalse (np .all (result [0 ]))
@@ -496,7 +499,7 @@ def test_dot_HS(self):
496
499
497
500
for d in rng .integers (2 , 10 , (5 ,)):
498
501
U , V = testutil .rand_herm (d , 2 )
499
- self .assertArrayAlmostEqual (util .dot_HS (U , V ), (U .conj ().T @ V ).trace ())
502
+ self .assertArrayAlmostEqual (util .dot_HS (U , V ), (U .conj ().T @ V ).trace ())
500
503
501
504
U = testutil .rand_unit (d ).squeeze ()
502
505
self .assertEqual (util .dot_HS (U , U ), d )
0 commit comments