| 88 | ], |
| 89 | ) |
| 90 | def test_two(kind, kwargs): |
| 91 | # The sums of observed and expected frequencies must match |
| 92 | a = np.random.random(size=30) |
| 93 | b = a[::-1] |
| 94 | |
| 95 | a_ = da.from_array(a, 3) |
| 96 | b_ = da.from_array(b, 3) |
| 97 | |
| 98 | dask_test = getattr(dask.array.stats, kind) |
| 99 | scipy_test = getattr(scipy.stats, kind) |
| 100 | |
| 101 | with warnings.catch_warnings(): # maybe overflow warning (power_divergence) |
| 102 | warnings.simplefilter("ignore", category=RuntimeWarning) |
| 103 | result = dask_test(a_, b_, **kwargs) |
| 104 | expected = scipy_test(a, b, **kwargs) |
| 105 | |
| 106 | assert isinstance(result, Delayed) |
| 107 | assert allclose(result.compute(), expected) |
| 108 | # fails occasionally. shouldn't this be exact? |
| 109 | # assert dask.compute(*result) == expected |
| 110 | |
| 111 | |
| 112 | @pytest.mark.parametrize("k", range(5)) |