QuantestPy / quantestpy

Apache License 2.0
9 stars 3 forks source link

Improve error message from assert methods which compare two matrices. #105

Closed junnaka51 closed 2 years ago

junnaka51 commented 2 years ago

What we have:

QuantestPyAssertionError: 
0th element:
a: 5.95376407192647e-06-1.83144834815201e-06j
b: 0.999924701839145-0.0122715382857199j

1th element:
a: 0.0122791987315662-0.999924607777856j
b: 0+0j

7th element:
a: -0.698370766144391+0.715736175525652j
b: 0+0j
...

What we want:

QuantestPyAssertionError: 
(0, 0) element:
a: 5.95376407192647e-06-1.83144834815201e-06j
b: 0.999924701839145-0.0122715382857199j

(0, 1) element:
a: 0.0122791987315662-0.999924607777856j
b: 0+0j

(2, 1) element:
a: -0.698370766144391+0.715736175525652j
b: 0+0j
...
junnaka51 commented 2 years ago

Before:

QuantestPyAssertionError: 
Not equal to tolerance rtol=0, atol=1e-08
Up to global phase: False
Mismatched elements: 4 / 4 (100%)
Max absolute difference: 1.
Max relative difference: 1.
 x: array([-1., -0., -0., -1.])
 y: array([0, 1, 1, 0])

After:

Not equal to tolerance rtol=0, atol=1e-08
Up to global phase: False
Mismatched elements: 4 / 4 (100%)
Max absolute difference: 1.
Max relative difference: 1.
 x: array([[-1., -0.],
       [-0., -1.]])
 y: array([[0, 1],
       [1, 0]])