Skip to content

Commit 2364e25

Browse files
authored
Change some truncrank args to kwargs (#22)
1 parent 2f89ab5 commit 2364e25

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MatrixAlgebraKit"
22
uuid = "6c742aac-3347-4629-af66-fc926824e5e4"
33
authors = ["Jutho <[email protected]> and contributors"]
4-
version = "0.1.2"
4+
version = "0.2.0"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/implementations/truncation.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ TruncationKeepBelow(atol::Real, rtol::Real) = TruncationKeepBelow(promote(atol,
6969

7070
# TODO: better names for these functions of the above types
7171
"""
72-
truncrank(howmany::Int, by=abs, rev=true)
72+
truncrank(howmany::Int; by=abs, rev=true)
7373
7474
Truncation strategy to keep the first `howmany` values when sorted according to `by` or the last `howmany` if `rev` is true.
7575
"""
76-
truncrank(howmany::Int, by=abs, rev=true) = TruncationKeepSorted(howmany, by, rev)
76+
truncrank(howmany::Int; by=abs, rev=true) = TruncationKeepSorted(howmany, by, rev)
7777

7878
"""
7979
trunctol(atol::Real)

test/truncate.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using MatrixAlgebraKit
22
using Test
33
using TestExtras
44
using MatrixAlgebraKit: NoTruncation, TruncationIntersection, TruncationKeepAbove,
5-
TruncationStrategy
5+
TruncationStrategy, findtruncated
66

77
@testset "truncate" begin
88
trunc = @constinferred TruncationStrategy()
@@ -26,4 +26,9 @@ using MatrixAlgebraKit: NoTruncation, TruncationIntersection, TruncationKeepAbov
2626
@test trunc == truncrank(10) & TruncationKeepAbove(1e-2, 1e-3)
2727
@test trunc.components[1] == truncrank(10)
2828
@test trunc.components[2] == TruncationKeepAbove(1e-2, 1e-3)
29+
30+
values = [1, 0.9, 0.5, 0.3, 0.01]
31+
@test @constinferred(findtruncated(values, truncrank(2))) == [1, 2]
32+
@test @constinferred(findtruncated(values, truncrank(2; rev=false))) == [5, 4]
33+
@test @constinferred(findtruncated(values, truncrank(2; by=-))) == [5, 4]
2934
end

0 commit comments

Comments
 (0)