Skip to content

Commit

Permalink
Add all nans stats test
Browse files Browse the repository at this point in the history
  • Loading branch information
e-koch committed Oct 18, 2024
1 parent d170bcd commit c97b587
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spectral_cube/tests/test_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ def test_statistics_withnans(data_adv):
rtol=1e-10)


def test_statistics_allnans(data_adv):
cube = DaskSpectralCube.read(data_adv).rechunk(chunks=(1, 2, 3))

# shape is 2, 3, 4
cube._data[:,:,:2] = np.nan
# ensure some chunks are all nan
cube.rechunk((1,2,2))
stats = cube.statistics()

for key in ('min', 'max', 'mean', 'sigma', 'rms'):
assert np.isnan(stats[key])

# Sum of NaNs is 0
assert stats['sum'] == 0 * cube.unit
assert stats['sumsq'] == (0 * cube.unit)**2


@pytest.mark.skipif(not CASA_INSTALLED, reason='Requires CASA to be installed')
def test_statistics_consistency_casa(data_adv, tmp_path):

Expand Down

0 comments on commit c97b587

Please sign in to comment.