Skip to content

Commit

Permalink
Fix statistics() when data is chunked
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Sep 22, 2020
1 parent 370525c commit 59265aa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spectral_cube/dask_spectral_cube.py
Expand Up @@ -735,7 +735,7 @@ def compute_stats(chunk, *args):
nansum(chunk * chunk)])

with dask.config.set(**self._scheduler_kwargs):
results = da.map_blocks(compute_stats, data).compute()
results = da.map_blocks(compute_stats, data.reshape(-1)).compute()

count_values, min_values, max_values, sum_values, ssum_values = results.reshape((-1, 5)).T

Expand Down
2 changes: 1 addition & 1 deletion spectral_cube/tests/test_dask.py
Expand Up @@ -77,7 +77,7 @@ def test_rechunk(data_adv):


def test_statistics(data_adv):
cube = DaskSpectralCube.read(data_adv)
cube = DaskSpectralCube.read(data_adv).rechunk(chunks=(1, 2, 3))
stats = cube.statistics()
assert_quantity_allclose(stats['npts'], 24)
assert_quantity_allclose(stats['mean'], 0.4941651776136591 * u.K)
Expand Down

0 comments on commit 59265aa

Please sign in to comment.