Skip to content

Commit ae2142f

Browse files
authored
Small fixes (#295)
* update truncation deprecations * fix typo in depwarn * fix `truncrank` when no value is truncated
1 parent 36bf5a4 commit ae2142f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/auxiliary/deprecate.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ Base.@deprecate insertunit(P::ProductSpace, args...; kwargs...) insertleftunit(a
5656
# truncations
5757
const TruncationScheme = MatrixAlgebraKit.TruncationStrategy
5858
@deprecate truncdim(d::Int) truncrank(d)
59-
@deprecate truncbelow::Real) trunctol(ϵ)
59+
@deprecate truncbelow::Real) trunctol(; atol = ϵ)
60+
@deprecate truncerr::Real) truncerror(ϵ)
6061

6162
# factorizations
6263
# --------------
@@ -131,7 +132,7 @@ function rightnull(t::AbstractTensorMap, p::Index2Tuple; kwargs...)
131132
return rightnull!(permutedcopy_oftype(t, factorisation_scalartype(rightnull, t), p); kwargs...)
132133
end
133134
function leftnull!(t::AbstractTensorMap; kwargs...)
134-
Base.depwarn("`left_null!` is deprecated, use `left_null!` instead", :leftnull!)
135+
Base.depwarn("`leftnull!` is deprecated, use `left_null!` instead", :leftnull!)
135136
haskey(kwargs, :alg) || return left_null!(t; kwargs...)
136137
alg = kwargs[:alg]
137138
kind = _kindof(alg)

src/factorizations/truncation.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,13 @@ function MAK.findtruncated_svd(values::SectorDict, strategy::TruncationByOrder)
165165
I = keytype(values)
166166
truncdim = SectorDict{I, Int}(c => length(d) for (c, d) in values)
167167
totaldim = sum(dim(c) * d for (c, d) in truncdim; init = 0)
168-
while true
168+
while totaldim > strategy.howmany
169169
next = _findnexttruncvalue(values, truncdim; strategy.by, strategy.rev)
170170
isnothing(next) && break
171171
_, cmin = next
172172
truncdim[cmin] -= 1
173173
totaldim -= dim(cmin)
174174
truncdim[cmin] == 0 && delete!(truncdim, cmin)
175-
totaldim <= strategy.howmany && break
176175
end
177176
return SectorDict(c => Base.OneTo(d) for (c, d) in truncdim)
178177
end

0 commit comments

Comments
 (0)