Skip to content

Possible bug in any(f::Function,A::ArrayPartition) #196

@SalmonLA

Description

@SalmonLA
julia> using RecursiveArrayTools

julia> a = ArrayPartition([NaN])
([NaN],)

julia> any(isnan,a)
false

julia> any(isnan,a[:]) #dispatches on Base.any instead
true

The responsible commit is years old, but I cannot see how this could be intended.
The current implementation applies the function twice, and would probably return false in many cases, where f does not ask about booleans:
Base.any(f::Function,A::ArrayPartition) = any(f,(any(f,x) for x in A.x))

Perhaps, this is what it was supposed to be:
Base.any(f::Function,A::ArrayPartition) = any((any(f,x) for x in A.x))

In this case however, we might as well dispatch to the generic Base.any function, so maybe I am missing something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions