Skip to content

Commit 2854e4d

Browse files
authored
Merge pull request #346 from fslaborg/fix-#345-removeColAt
fix removeColAt indexing
2 parents 9557768 + a039a25 commit 2854e4d

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

src/FSharp.Stats/Matrix.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ module Matrix =
14931493
else
14941494
loop (nColI) (colI-1)
14951495

1496-
loop (nRows-2) (nRows-1)
1496+
loop (nCols-2) (nCols-1)
14971497

14981498
/// <summary>Splits a matrix along row direction according to given indices. Returns (matrix including rows according to indices, rest)</summary>
14991499
/// <remarks></remarks>

tests/FSharp.Stats.Tests/FSharp.Stats.Tests.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<ItemGroup>
7575
<PackageReference Include="altcover" Version="8.6.68" />
7676
<PackageReference Include="Expecto" Version="10.*" />
77-
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.*" />
77+
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.14.*" />
7878
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
7979
<PackageReference Include="OptimizedPriorityQueue" Version="5.1.0" />
8080
<PackageReference Include="Deedle" Version="3.0.0" />

tests/FSharp.Stats.Tests/Matrix.fs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,37 @@ let floatImplementationDenseTests =
11831183
testCase "getRows" <| fun () ->
11841184
()
11851185
]
1186+
testList "removeCols" [
1187+
testCase "removeColAt" <| fun () ->
1188+
let m =
1189+
[|
1190+
[|0.;1.|]
1191+
[|0.;3.|]
1192+
[|0.;5.|]
1193+
|] |> Matrix.ofJaggedArray
1194+
let actual = Matrix.removeColAt 0 m
1195+
let expected =
1196+
[|
1197+
[|1.|]
1198+
[|3.|]
1199+
[|5.|]
1200+
|] |> Matrix.ofJaggedArray
1201+
Expect.equal actual expected "Matrix.removeColAt did not return the correct matrix"
1202+
]
1203+
testList "removeRows" [
1204+
testCase "removeRowAt" <| fun () ->
1205+
let m =
1206+
[|
1207+
[|0.;0.;0.;|]
1208+
[|1.;3.;5.;|]
1209+
|] |> Matrix.ofJaggedArray
1210+
let actual = Matrix.removeRowAt 1 m
1211+
let expected =
1212+
[|
1213+
[|0.;0.;0.|]
1214+
|] |> Matrix.ofJaggedArray
1215+
Expect.equal actual expected "Matrix.removeRowAt did not return the correct matrix"
1216+
]
11861217
testList "getRegion" [
11871218

11881219
testCase "get Region" <| fun () ->

0 commit comments

Comments
 (0)