lincc-frameworks / tdastro

MIT License
4 stars 0 forks source link

test_numpy_random_uniform_multi fails stochastically #101

Closed hombit closed 1 month ago

hombit commented 2 months ago

Bug report

A message I've got during a pre-commit unit-test run:

_______________________ test_numpy_random_uniform_multi ________________________

    def test_numpy_random_uniform_multi():
        """Test that we can many generate numbers at once from a uniform distribution."""
        np_node = NumpyRandomFunc("uniform")
        state = np_node.sample_parameters(num_samples=10_000)
        samples = np_node.get_param(state, "function_node_result")
        assert len(samples) == 10_000
        assert len(np.unique(samples)) > 1_000
>       assert np.abs(np.mean(samples) - 0.5) < 0.01
E       AssertionError: assert 0.010174081407210656 < 0.01
E        +  where 0.010174081407210656 = <ufunc 'absolute'>((0.5101740814072107 - 0.5))
E        +    where <ufunc 'absolute'> = np.abs
E        +    and   0.5101740814072107 = <function mean at 0x1050a3730>(array([0.17279315, 0.81927332, 0.5092465 , ..., 0.17233423, 0.82553945,\n       0.21014224]))
E        +      where <function mean at 0x1050a3730> = np.mean

tests/tdastro/util_nodes/test_np_random.py:75: AssertionError

Before submitting Please check the following: