google / TensorNetwork

A library for easy and efficient manipulation of tensor networks.
Apache License 2.0
1.82k stars 359 forks source link

Flaky test (always fails) when seeds are removed #945

Open crawlingcub opened 3 years ago

crawlingcub commented 3 years ago

Hi,

The test test_randn_non_zero_imag in tensornetwork/backends/symmetric/symmetric_backend_test.py link always fails when the seeds are removed. The test only fails for parameters: [2-complex64-2] and [2-complex128-2], but passes for all other parameters. In particular, the assertion at line 490 fails (500 fails out of 500 runs).

Is this expected behavior? Or indicative of a bug or some approximations? Please let me know if you need more info. Thanks!

Error message:

>     assert np.linalg.norm(np.imag(actual.data)) != 0.0
E     AssertionError: assert 0.0 != 0.0
E      +  where 0.0 = <function norm at 0x7fc3575258c8>(array([], dtype=float64))
E      +    where <function norm at 0x7fc3575258c8> = <module 'numpy.linalg' from '/...s/TensorNetwork/lib/python3.6/site-packages/numpy/linalg/__init__.py'>.norm
E      +      where <module 'numpy.linalg' from '/.../envs/TensorNetwork/lib/python3.6/site-packages/numpy/linalg/__init__.py'> = np.linalg
E      +    and   array([], dtype=float64) = <function imag at 0x7fc35799ebf8>(array([], dtype=complex128))
E      +      where <function imag at 0x7fc35799ebf8> = np.imag
E      +      and   array([], dtype=complex128) = BlockSparseTensor\n   shape: (10, 10)\n   charge types: ['U1Charge', 'U1Charge']\n   dtype: 'complex128'\n   flat flows: [False, False]\n   order: [[0], [1]].\
data

tensornetwork/backends/symmetric/symmetric_backend_test.py:490: AssertionError
crawlingcub commented 3 years ago

Adding @mganahl