Skip to content

Commit c6c5053

Browse files
3rdCorefindmyway
andauthored
fixed findmax unconsistency (#521)
* fixed Base.findmax unconsistency * Update src/ReinforcementLearningCore/src/utils/base.jl Co-authored-by: Jun Tian <find_my_way@foxmail.com> Co-authored-by: Jun Tian <find_my_way@foxmail.com>
1 parent e2c4673 commit c6c5053

File tree

1 file changed

+1
-2
lines changed
  • src/ReinforcementLearningCore/src/utils

1 file changed

+1
-2
lines changed

src/ReinforcementLearningCore/src/utils/base.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ end
149149
# _rf_findmax((fm, m), (fx, x)) = isless(fm, fx) ? (fx, x) : (fm, m)
150150

151151
# !!! type piracy
152-
Base.findmax(A::AbstractVector, mask::AbstractVector{Bool}) =
153-
findmax(i -> A[i], view(keys(A), mask))
152+
Base.findmax(A::AbstractVector{T}, mask::AbstractVector{Bool}) where T = findmax(ifelse.(mask, A, typemin(T)))
154153

155154

156155
const VectorOrMatrix = Union{AbstractMatrix,AbstractVector}

0 commit comments

Comments
 (0)