Beispiel #1
0
        public void TestIntTimeSeriesDownsampling()
        {
            var timeseries = new TimeSeriesStream <int>(span);

            timeseries[0] = 1;
            timeseries[3] = 23;
            timeseries[7] = 43;
            timeseries[8] = 5;
            timeseries[9] = 99;

            var resampler = new TimeSeriesResampler <TimeSeriesStream <int>, int>(spanDownsampling);

            resampler.SampleAccumulate(timeseries);

            Assert.Equal(new List <int>()
            {
                1, 23, -1, 43, 104
            }, resampler.Resampled.Trimmed(-1));
        }
Beispiel #2
0
        public void TestIntTimeSeriesUpsampling()
        {
            var timeseries = new TimeSeriesStream <int>(span);

            timeseries[0] = 1;
            timeseries[3] = 23;
            timeseries[7] = 43;
            timeseries[8] = 5;
            timeseries[9] = 99;

            var resampler = new TimeSeriesResampler <TimeSeriesStream <int>, int>(spanUpsampling);

            resampler.SampleAccumulate(timeseries);

            // should upsample, because no oversample constraint was set
            Assert.Equal(new List <int>()
            {
                1, -1, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, -1, 43, -1, 5, -1, 99
            }, resampler.Resampled.Trimmed(-1));
        }
Beispiel #3
0
        public void TestIntTimeSeriesDownsamplingNoOversampling()
        {
            var timeseries = new TimeSeriesStream <int>(span);

            timeseries[0] = 1;
            timeseries[3] = 23;
            timeseries[7] = 43;
            timeseries[8] = 5;
            timeseries[9] = 99;

            var resampler = new TimeSeriesResampler <TimeSeriesStream <int>, int>(spanDownsampling, SamplingConstraint.NoOversampling);

            resampler.SampleAccumulate(timeseries);

            // should downsample, because oversampling only happens while upsampling
            Assert.Equal(new List <int>()
            {
                1, 23, -1, 43, 104
            }, resampler.Resampled.Trimmed(-1));
        }
Beispiel #4
0
        public void TestIntTimeSeriesUpDownsampling()
        {
            var timeseries = new TimeSeriesStream <int>(span);

            timeseries[0] = 1;
            timeseries[3] = 23;
            timeseries[7] = 43;
            timeseries[8] = 5;
            timeseries[9] = 99;

            // upsample
            var resampler = new TimeSeriesResampler <TimeSeriesStream <int>, int>(spanUpsampling);

            resampler.SampleAccumulate(timeseries);

            // downsample to the original
            var resampler2 = new TimeSeriesResampler <TimeSeriesStream <int>, int>(span);

            resampler2.SampleAccumulate(resampler.Resampled);

            Assert.Equal(timeseries.Trimmed(-1), resampler2.Resampled.Trimmed(-1));
        }