Skip to content

Commit e437809

Browse files
committed
Fix all with ArrayPartition and a functor
1 parent 6cdda9c commit e437809

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/array_partition.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ Base.filter(f, A::ArrayPartition) = ArrayPartition(map(x -> filter(f, x), A.x))
226226
Base.any(f, A::ArrayPartition) = any((any(f, x) for x in A.x))
227227
Base.any(f::Function, A::ArrayPartition) = any((any(f, x) for x in A.x))
228228
Base.any(A::ArrayPartition) = any(identity, A)
229-
Base.all(f, A::ArrayPartition) = all(f, (all(f, x) for x in A.x))
229+
Base.all(f, A::ArrayPartition) = all((all(f, x) for x in A.x))
230230
Base.all(f::Function, A::ArrayPartition) = all((all(f, x) for x in A.x))
231231
Base.all(A::ArrayPartition) = all(identity, A)
232232

test/partitions_test.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,8 @@ for i in 1:length(part_a.x)
370370
@test sub_a == sub_b # Test for value equality
371371
@test typeof(sub_a) === typeof(sub_b) # Test type equality
372372
end
373+
374+
# ArrayPartition `all` with a functor
375+
struct TestIsnanFunctor end
376+
(::TestIsnanFunctor)(x) = isnan(x)
377+
@test all(TestIsnanFunctor(), ArrayPartition([NaN], [NaN]))

0 commit comments

Comments
 (0)