//  [python]
def test_resample_new(self):
        """
        Tests if Trace.resample works as expected and test that issue #857 is
        resolved.
        """
        starttime = UTC("1970-01-01T00:00:00.000000Z")
        tr0 = Trace(np.sin(np.linspace(0, 2 * np.pi, 10)),
                    {'sampling_rate': 1.0,
                     'starttime': starttime})
        # downsample
        tr = tr0.copy()
        tr.resample(0.5, window='hann', no_filter=True)
        assert len(tr.data) == 5
        expected = np.array([0.19478735, 0.83618307, 0.32200221,
                             -0.7794053, -0.57356732])
        assert np.all(np.abs(tr.data - expected) < 1e-7)
        assert tr.stats.sampling_rate == 0.5
        assert tr.stats.delta == 2.0
        assert tr.stats.npts == 5
        assert tr.stats.starttime == starttime
        assert tr.stats.endtime == \
               starttime + tr.stats.delta * (tr.stats.npts - 1)

        # upsample
        tr = tr0.copy()
        tr.resample(2.0, window='hann', no_filter=True)
        assert len(tr.data) == 20
        assert tr.stats.sampling_rate == 2.0
        assert tr.stats.delta == 0.5
        assert tr.stats.npts == 20
        assert tr.stats.starttime == starttime
        assert tr.stats.endtime == \
               starttime + tr.stats.delta * (tr.stats.npts - 1)

        # downsample with non integer ratio
        tr = tr0.copy()
        tr.resample(0.75, window='hann', no_filter=True)
        assert len(tr.data) == int(10 * .75)
        expected = np.array([0.15425413, 0.66991128, 0.74610418, 0.11960477,
                             -0.60644662, -0.77403839, -0.30938935])
        assert np.all(np.abs(tr.data - expected) < 1e-7)
        assert tr.stats.sampling_rate == 0.75
        assert tr.stats.delta == 1 / 0.75
        assert tr.stats.npts == int(10 * .75)
        assert tr.stats.starttime == starttime
        assert tr.stats.endtime == \
               starttime + tr.stats.delta * (tr.stats.npts - 1)

        # downsample without window
        tr = tr0.copy()
        tr.resample(0.5, window=None, no_filter=True)
        assert len(tr.data) == 5
        assert tr.stats.sampling_rate == 0.5
        assert tr.stats.delta == 2.0
        assert tr.stats.npts == 5
        assert tr.stats.starttime == starttime
        assert tr.stats.endtime == \
               starttime + tr.stats.delta * (tr.stats.npts - 1)

        # downsample with window and automatic filtering
        tr = tr0.copy()
        tr.resample(0.5, window='hann', no_filter=False)
        assert len(tr.data) == 5
        assert tr.stats.sampling_rate == 0.5
        assert tr.stats.delta == 2.0
        assert tr.stats.npts == 5
        assert tr.stats.starttime == starttime
        assert tr.stats.endtime == \
               starttime + tr.stats.delta * (tr.stats.npts - 1)

        # downsample with custom window
        tr = tr0.copy()
        window = np.ones((tr.stats.npts))
        tr.resample(0.5, window=window, no_filter=True)

        # downsample with bad window
        tr = tr0.copy()
        window = np.array([0, 1, 2, 3])
        with pytest.raises(ValueError):
            tr.resample(sampling_rate=0.5, window=window, no_filter=True)