Closed marklam closed 1 year ago
Thanks for reporting!:rocket: I've traced down the issue to the following two lines:
The Array.rev
must be removed at:
https://github.com/fslaborg/FSharp.Stats/blob/3d6a2201c45d792d95cc127c97c377fa4bcf496c/src/FSharp.Stats/Signal/Padding.fs#L140-L144
The last point has to be integrated here: https://github.com/fslaborg/FSharp.Stats/blob/3d6a2201c45d792d95cc127c97c377fa4bcf496c/src/FSharp.Stats/Signal/Padding.fs#L164-L167
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 153d95ed3507018326fbb86b707b949a7b741e38
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.