def test_rasterize_gracefully_handles_band_with_no_energy(self):
     n_bands = 8
     td = TimeDimension(duration=Seconds(1), frequency=Milliseconds(500))
     scale = GeometricScale(start_center_hz=50,
                            stop_center_hz=5000,
                            bandwidth_ratio=0.07123,
                            n_bands=n_bands)
     arrs = [
         np.random.normal(0, 1, (10, 2**(i + 1))) for i in xrange(n_bands)
     ]
     arrs[0][:] = 0
     fa = FrequencyAdaptive(arrs, td, scale)
     rasterized = fa.rasterize(n_coeffs=32)
     np.testing.assert_allclose(rasterized[:, :, 0], 0)
 def test_rasterize_does_not_distort_spectral_shape(self):
     n_bands = 8
     td = TimeDimension(duration=Seconds(1), frequency=Milliseconds(500))
     scale = GeometricScale(start_center_hz=50,
                            stop_center_hz=5000,
                            bandwidth_ratio=0.07123,
                            n_bands=n_bands)
     arrs = [
         np.random.normal(0, 1, (10, 2**(i + 1))) for i in xrange(n_bands)
     ]
     maxes = [arr.max() for arr in arrs]
     fa = FrequencyAdaptive(arrs, td, scale)
     rasterized = fa.rasterize(n_coeffs=32)
     np.testing.assert_allclose(rasterized.max(axis=(0, 1)), maxes)