Skip to content

Commit dad7df2

Browse files
committed
Fix logic for empty sets and fast any.
Now logic in the Manopt universe is fixed again.
1 parent 73e9a6d commit dad7df2

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/plans/stopping_criterion.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,8 +1169,11 @@ end
11691169

11701170
# `_fast_any(f, tup::Tuple)`` is functionally equivalent to `any(f, tup)`` but on Julia 1.10
11711171
# this implementation is faster on heterogeneous tuples
1172+
# for length zero -> return false
11721173
@inline _fast_any(f, tup::Tuple{}) = false
1174+
# for one-element tuples, evaluate that one element
11731175
@inline _fast_any(f, tup::Tuple{T}) where {T} = f(tup[1])
1176+
# for more than that -> finish fast, if the first is true end checks, otherwise continue with tail
11741177
@inline function _fast_any(f, tup::Tuple)
11751178
if f(tup[1])
11761179
return true

test/plans/test_stopping_criteria.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ end
4848
@test get_reason(sn) == ""
4949
@test !Manopt.indicates_convergence(sn) # since it might stop after 10 iterations
5050
@test repr(sn) == "StopWhenAny([$(repr(sn1)), $(repr(s3))])"
51-
@test_broken Manopt._fast_any(x -> false, ())
51+
# or over an empty set has to be false for any function
52+
@test !Manopt._fast_any(x -> false, ())
5253

5354
sn2 = StopAfterIteration(10) | s3
5455
@test get_stopping_criteria(sn)[1].max_iterations ==

0 commit comments

Comments
 (0)