Deedle icon indicating copy to clipboard operation
Deedle copied to clipboard

Lazy series interaction with Sample is broken

Open adamklein opened this issue 9 years ago • 3 comments

A little subtle, giving a full example:

public static async Task<Series<DateTime, double>> LazyData(DateTime d1, DateTime d2) {
    var ts = new SeriesBuilder<DateTime, double>();
    var d0 = d1;
    var v = 0.0;
    while (d0 <= d2) {
        ts.Add(d0, v);
        d0 = d0.AddSeconds(1);
        v += 1;
    }
    return ts.ToSeries();
}

void Main()
{
    var start = new DateTime(2014, 1, 2);
    var end   = new DateTime(2014, 1, 3);   
    var ts = DelayedSeries.Create<DateTime,double>(start, end, 
        async (lo, _, hi, __) => { 
            var x = await LazyData(lo, hi); 
            return x.Observations; 
        });

    var ds = new DateTime(2014, 1, 2);
    var de = ds.AddSeconds(20); // ds.AddDays(1).AddTicks(-1);

    // ok:
    // ts.Between(ds, de).Materialize().Sample(ds, TimeSpan.FromSeconds(5), Direction.Forward).Format().Dump(); 

    // fails: prints out data from 1/2/14 through 1/3/14 at 5 second intervals
    ts.Between(ds, de).Sample(ds, TimeSpan.FromSeconds(5), Direction.Forward).Format().Dump();
}

adamklein avatar Jun 05 '15 19:06 adamklein

(sample is linqpad script, hence Dump() call)

adamklein avatar Jun 05 '15 19:06 adamklein

PS we should basically just run the whole Series test suite on a lazy series :)

adamklein avatar Jun 05 '15 19:06 adamklein

Oh.. I'll investigate.

Finding some way to run the tests on different kinds of series (lazy, big Deedle) is actually a great idea!

tpetricek avatar Jun 07 '15 15:06 tpetricek