-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Padding.pad drops a data element, and the end padding is backwards #265
Comments
Thanks for reporting!:rocket: The FSharp.Stats/src/FSharp.Stats/Signal/Padding.fs Lines 140 to 144 in 3d6a220
The last point has to be integrated here: FSharp.Stats/src/FSharp.Stats/Signal/Padding.fs Lines 164 to 167 in 3d6a220
After these modifications the result looks as follows: //#r "nuget:FSharp.Stats"
#r @"C:\Users\bvenn\source\repos\FSharp.Stats\src\FSharp.Stats\bin\Release\netstandard2.0\FSharp.Stats.dll"
#r "nuget:Expecto"
#r "nuget: Plotly.NET"
open Plotly.NET
open System
open FSharp.Stats.Signal
open Expecto
let dataLength = 20
let padding = 10
let data =
Array.init dataLength (
fun i ->
(3.0 + float i, 7.0 - float i)
)
let expectLeadIn = Array.init padding (fun i -> (3.0 - float (padding-i), 0.0))
let expectLeadOut = Array.init padding (fun i -> (3.0 + float (dataLength + i), 0.0))
let expectedPadded = Array.concat [expectLeadIn; data; expectLeadOut]
let padded =
Padding.pad data 1.0 Double.PositiveInfinity (-) (+) padding Padding.BorderPaddingMethod.Zero Padding.InternalPaddingMethod.NaN Padding.HugeGapPaddingMethod.NaN
let indices = Array.init padded.Length (fun x -> string x)
[
Chart.Point(data,Name="raw data") |> Chart.withMarkerStyle (Size=10)
Chart.Point(expectedPadded,Name="expected") |> Chart.withMarkerStyle (Size=8)
Chart.Point(padded,Name="actual",MultiText=indices,TextPosition=StyleParam.TextPosition.TopRight) |> Chart.withMarkerStyle (Size=6)
]
|> Chart.combine
|> Chart.show @marklam, if it is ok for you I would integrate your tests into the test project. Of course you can add them yourself and file a PR if you want to. |
@bvenn I'm more than happy for you to integrate those tests. Thanks for responding so quickly! |
closed by 153d95e |
Describe the bug
FSharp.Stats.Signal.Padding.pad loses the last data point, and the end padding is reversed.
If padding (X,100) .. (Y-1,199); (Y,200) with 3 zero-valued items and a minDistance of 1.0 you should get:
but you actually get
so (Y,200) is lost, and the padding elements at the end are reversed.
To Reproduce
Expected behavior
The padded data should have all the original data, with the same number of padding elements at each end. The
fst
of each padding data element should increase byminDistance
.Screenshots
If applicable, add screenshots to help explain your problem.
OS and framework information (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: