Skip to content

Commit 1ba3065

Browse files
fix: rename corrMatrix/covMatrix to corrFrame/covFrame to avoid Deedle.Math overload collision
Stats.corrMatrix and Stats.covMatrix in Deedle.Math return Matrix<float> (via MathNet.Numerics). The newly added functions in Deedle core with the same names return Frame<'C,'C>, causing F# overload ambiguity that broke PCA.fs, Finance.fs and Stats.fs in Deedle.Math. Rename the core functions to corrFrame / covFrame, which: - Eliminates the name collision with Deedle.Math's Matrix-returning variants - Better conveys the return type (a Frame, not a Matrix) - Follows the existing Deedle.Math convention where 'corr'/'cov' (no suffix) return a Frame and 'corrMatrix'/'covMatrix' return a Matrix Co-authored-by: Copilot <[email protected]>
1 parent 5986132 commit 1ba3065

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/Deedle/Stats.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ type Stats =
11101110
/// </summary>
11111111
/// <param name="frame">The input frame</param>
11121112
/// <category>Frame statistics</category>
1113-
static member corrMatrix (frame:Frame<'R, 'C>) =
1113+
static member corrFrame (frame:Frame<'R, 'C>) =
11141114
let cols = frame.GetColumns<float>() |> Series.observations |> Seq.toArray
11151115
cols
11161116
|> Array.map (fun (c2, s2) ->
@@ -1129,7 +1129,7 @@ type Stats =
11291129
/// </summary>
11301130
/// <param name="frame">The input frame</param>
11311131
/// <category>Frame statistics</category>
1132-
static member covMatrix (frame:Frame<'R, 'C>) =
1132+
static member covFrame (frame:Frame<'R, 'C>) =
11331133
let cols = frame.GetColumns<float>() |> Series.observations |> Seq.toArray
11341134
cols
11351135
|> Array.map (fun (c2, s2) ->

tests/Deedle.Tests/Stats.fs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -708,43 +708,43 @@ let ``Stats.corr returns NaN for fewer than 2 pairs`` () =
708708
// ------------------------------------------------------------------------------------------------
709709

710710
[<Test>]
711-
let ``Stats.corrMatrix diagonal entries are 1.0`` () =
711+
let ``Stats.corrFrame diagonal entries are 1.0`` () =
712712
let f = frame [ "A" => series [1=>1.0; 2=>2.0; 3=>3.0]
713713
"B" => series [1=>3.0; 2=>1.0; 3=>2.0] ]
714-
let m = Stats.corrMatrix f
714+
let m = Stats.corrFrame f
715715
m.GetColumn<float>("A").Get("A") |> should beWithin (1.0 +/- 1e-9)
716716
m.GetColumn<float>("B").Get("B") |> should beWithin (1.0 +/- 1e-9)
717717

718718
[<Test>]
719-
let ``Stats.corrMatrix is symmetric`` () =
719+
let ``Stats.corrFrame is symmetric`` () =
720720
let f = frame [ "A" => series [1=>1.0; 2=>2.0; 3=>3.0]
721721
"B" => series [1=>3.0; 2=>1.0; 3=>2.0] ]
722-
let m = Stats.corrMatrix f
722+
let m = Stats.corrFrame f
723723
let ab = m.GetColumn<float>("A").Get("B")
724724
let ba = m.GetColumn<float>("B").Get("A")
725725
ab |> should beWithin (ba +/- 1e-9)
726726

727727
[<Test>]
728-
let ``Stats.corrMatrix perfectly correlated columns give 1.0`` () =
728+
let ``Stats.corrFrame perfectly correlated columns give 1.0`` () =
729729
let f = frame [ "A" => series [1=>1.0; 2=>2.0; 3=>3.0; 4=>4.0]
730730
"B" => series [1=>2.0; 2=>4.0; 3=>6.0; 4=>8.0] ]
731-
let m = Stats.corrMatrix f
731+
let m = Stats.corrFrame f
732732
m.GetColumn<float>("A").Get("B") |> should beWithin (1.0 +/- 1e-9)
733733

734734
[<Test>]
735-
let ``Stats.covMatrix diagonal entries equal variance`` () =
735+
let ``Stats.covFrame diagonal entries equal variance`` () =
736736
let f = frame [ "A" => series [1=>1.0; 2=>2.0; 3=>3.0; 4=>4.0]
737737
"B" => series [1=>2.0; 2=>4.0; 3=>6.0; 4=>8.0] ]
738-
let m = Stats.covMatrix f
738+
let m = Stats.covFrame f
739739
// Diagonal entry (A,A) = Var(A) = sample variance of [1,2,3,4]
740740
let expected = Stats.variance (Series.ofValues [1.0;2.0;3.0;4.0])
741741
m.GetColumn<float>("A").Get("A") |> should beWithin (expected +/- 1e-9)
742742

743743
[<Test>]
744-
let ``Stats.covMatrix is symmetric`` () =
744+
let ``Stats.covFrame is symmetric`` () =
745745
let f = frame [ "A" => series [1=>1.0; 2=>2.0; 3=>3.0]
746746
"B" => series [1=>3.0; 2=>1.0; 3=>2.0] ]
747-
let m = Stats.covMatrix f
747+
let m = Stats.covFrame f
748748
let ab = m.GetColumn<float>("A").Get("B")
749749
let ba = m.GetColumn<float>("B").Get("A")
750750
ab |> should beWithin (ba +/- 1e-9)

0 commit comments

Comments
 (0)