fslaborg / Deedle

Easy to use .NET library for data and time series manipulation and for scientific programming
http://fslab.org/Deedle/
BSD 2-Clause "Simplified" License
935 stars 195 forks source link

DelayedSeries intersection of ranges produces invalid output #223

Closed adamklein closed 10 years ago

adamklein commented 10 years ago

I will submit a test & fix shortly. In sum, the intersection of ranges (via Between) can include a [lo, hi] pair with hi < lo, and then return a non-empty series because the flattenRanges function in DelayedSeries.fs sorts the boundaries without checking for this problem.

adamklein commented 10 years ago

Here is the test. I have a working solution... soon!

[<Test>]
let ``Multiple conflicting range restrictions lead to empty results`` () =
  let ls = DelayedSeries.Create(0, 100, fun _ _ -> async { 
    return seq { for i in 0 .. 100 -> KeyValue.Create(i, i) } })   
  ls.Between(90,89).KeyCount |> shouldEqual 0
tpetricek commented 10 years ago

I added the test cases that you mentioned in the earlier pull request and fixed the bug that was causing it (and I also added a test for the case that I suspected could be wrong, but was actually handled correctly).

The diff is here: https://github.com/tpetricek/Deedle/commit/f78b7d87f91e0f984c09293d0c71305e7c9971f1

And the updated pull request is: https://github.com/BlueMountainCapital/Deedle/pull/229