From 2a64b1bb640623950cedda4048ca86ae248ef4fc Mon Sep 17 00:00:00 2001 From: bvenn Date: Sun, 22 Jun 2025 11:26:19 +0200 Subject: [PATCH 1/3] closes #345 fix removeColAt indexing add tests --- src/FSharp.Stats/Matrix.fs | 2 +- tests/FSharp.Stats.Tests/Matrix.fs | 31 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/FSharp.Stats/Matrix.fs b/src/FSharp.Stats/Matrix.fs index cac019ca..cbf71faf 100644 --- a/src/FSharp.Stats/Matrix.fs +++ b/src/FSharp.Stats/Matrix.fs @@ -1493,7 +1493,7 @@ module Matrix = else loop (nColI) (colI-1) - loop (nRows-2) (nRows-1) + loop (nCols-2) (nCols-1) /// Splits a matrix along row direction according to given indices. Returns (matrix including rows according to indices, rest) /// diff --git a/tests/FSharp.Stats.Tests/Matrix.fs b/tests/FSharp.Stats.Tests/Matrix.fs index 519ebf23..a434f127 100644 --- a/tests/FSharp.Stats.Tests/Matrix.fs +++ b/tests/FSharp.Stats.Tests/Matrix.fs @@ -1183,6 +1183,37 @@ let floatImplementationDenseTests = testCase "getRows" <| fun () -> () ] + testList "removeCols" [ + testCase "removeColAt" <| fun () -> + let m = + [| + [|0.;1.|] + [|0.;3.|] + [|0.;5.|] + |] |> Matrix.ofJaggedArray + let actual = Matrix.removeColAt 0 m + let expected = + [| + [|1.|] + [|3.|] + [|5.|] + |] + Expect.equal actual expected "Matrix.removeColAt did not return the correct matrix" + ] + testList "removeRows" [ + testCase "removeRowAt" <| fun () -> + let m = + [| + [|0.;0.;0.;|] + [|1.;3.;5.;|] + |] |> Matrix.ofJaggedArray + let actual = Matrix.removeRowAt 1 m + let expected = + [| + [|0.;0.;0.|] + |] + Expect.equal actual expected "Matrix.removeRowAt did not return the correct matrix" + ] testList "getRegion" [ testCase "get Region" <| fun () -> From 2316e21404f302cf808af445d4c83c5c1229a3ae Mon Sep 17 00:00:00 2001 From: bvenn Date: Sun, 22 Jun 2025 11:40:38 +0200 Subject: [PATCH 2/3] update test types --- tests/FSharp.Stats.Tests/Matrix.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Stats.Tests/Matrix.fs b/tests/FSharp.Stats.Tests/Matrix.fs index a434f127..754f450e 100644 --- a/tests/FSharp.Stats.Tests/Matrix.fs +++ b/tests/FSharp.Stats.Tests/Matrix.fs @@ -1197,7 +1197,7 @@ let floatImplementationDenseTests = [|1.|] [|3.|] [|5.|] - |] + |] |> Matrix.ofJaggedArray Expect.equal actual expected "Matrix.removeColAt did not return the correct matrix" ] testList "removeRows" [ @@ -1211,7 +1211,7 @@ let floatImplementationDenseTests = let expected = [| [|0.;0.;0.|] - |] + |] |> Matrix.ofJaggedArray Expect.equal actual expected "Matrix.removeRowAt did not return the correct matrix" ] testList "getRegion" [ From a039a250c11791b79a7fb9776ce45e29a67ef131 Mon Sep 17 00:00:00 2001 From: bvenn Date: Sun, 22 Jun 2025 11:42:40 +0200 Subject: [PATCH 3/3] downgrade expecto version --- tests/FSharp.Stats.Tests/FSharp.Stats.Tests.fsproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Stats.Tests/FSharp.Stats.Tests.fsproj b/tests/FSharp.Stats.Tests/FSharp.Stats.Tests.fsproj index 0a373c39..af6b5eb2 100644 --- a/tests/FSharp.Stats.Tests/FSharp.Stats.Tests.fsproj +++ b/tests/FSharp.Stats.Tests/FSharp.Stats.Tests.fsproj @@ -74,7 +74,7 @@ - +