Skip to content

Commit e06f0e2

Browse files
committed
Simplify with findall
1 parent bd727d1 commit e06f0e2

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/implementations/truncation.jl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,7 @@ function findtruncated_sorted(values::AbstractVector, strategy::TruncationKeepBe
206206
end
207207
function findtruncated_unsorted(values::AbstractVector, strategy::TruncationKeepBelow)
208208
atol = max(strategy.atol, strategy.rtol * maximum(values))
209-
sorted = sortperm(values; by=abs, rev=true)
210-
i = @something findfirst((atol), values[sorted]) length(values) + 1
211-
ind = sorted[i:length(values)]
212-
return ind # TODO: consider sort!(ind)
209+
return findall((atol), values)
213210
end
214211

215212
function findtruncated(values::AbstractVector, strategy::TruncationKeepAbove)
@@ -226,10 +223,7 @@ function findtruncated_sorted(values::AbstractVector, strategy::TruncationKeepAb
226223
end
227224
function findtruncated_unsorted(values::AbstractVector, strategy::TruncationKeepAbove)
228225
atol = max(strategy.atol, strategy.rtol * maximum(values))
229-
sorted = sortperm(values; by=abs, rev=true)
230-
i = @something findlast((atol), values[sorted]) 0
231-
ind = sorted[1:i]
232-
return ind # TODO: consider sort!(ind)
226+
return findall((atol), values)
233227
end
234228

235229
function findtruncated(values::AbstractVector, strategy::TruncationIntersection)

0 commit comments

Comments
 (0)