Skip to content

Commit

Permalink
Merge pull request #467 from keflavich/another_stacker_fix
Browse files Browse the repository at this point in the history
Addendum to 466
  • Loading branch information
keflavich committed Feb 7, 2018
2 parents 9761584 + b7913d5 commit fecde77
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions spectral_cube/tests/test_analysis_functions.py
Expand Up @@ -240,6 +240,45 @@ def test_stacking_woffset():
or (stacked.size == stack_shape + 1)


def test_stacking_shape_failure():
"""
Regression test for #466
"""
amp = 1.
v0 = 0. * u.km / u.s
sigma = 8.
noise = None
shape = (100, 25, 25)

test_cube, test_vels = \
generate_gaussian_cube(amp=amp, sigma=sigma, noise=noise,
shape=shape)

# make the test_vels array the wrong shape
test_vels = test_vels[:-1, :-1]

with pytest.raises(ValueError) as exc:
stack_spectra(test_cube, test_vels, v0=v0,
stack_function=np.nanmean,
xy_posns=None, num_cores=1,
chunk_size=-1,
progressbar=False, pad_edges=False)

assert 'Velocity surface map does not match' in exc.value.args[0]


test_vels = np.ones(shape[1:], dtype='float') + np.nan

with pytest.raises(ValueError) as exc:
stack_spectra(test_cube, test_vels, v0=v0,
stack_function=np.nanmean,
xy_posns=None, num_cores=1,
chunk_size=-1,
progressbar=False, pad_edges=False)

assert "velocity_surface contains no finite values" in exc.value.args[0]


def test_stacking_noisy():

# Test stack w/ S/N of 0.2
Expand Down

0 comments on commit fecde77

Please sign in to comment.