Skip to content

Commit e056066

Browse files
Merge pull request #141 from jonniedie/master
Faster `map` over `ArrayPartition`s.
2 parents 0a70724 + bf9443f commit e056066

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/array_partition.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Base.:(==)(A::ArrayPartition,B::ArrayPartition) = A.x == B.x
112112

113113
## Iterable Collection Constructs
114114

115+
Base.map(f,A::ArrayPartition) = ArrayPartition(map(x->map(f,x), A.x))
115116
Base.mapreduce(f,op,A::ArrayPartition) = mapreduce(f,op,(mapreduce(f,op,x) for x in A.x))
116117
Base.any(f,A::ArrayPartition) = any(f,(any(f,x) for x in A.x))
117118
Base.any(f::Function,A::ArrayPartition) = any(f,(any(f,x) for x in A.x))

test/partitions_test.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ _broadcast_wrapper(y) = _scalar_op.(y)
103103
# Issue #8
104104
# @inferred _broadcast_wrapper(x)
105105

106+
# Testing map
107+
@test map(x->x^2, x) == ArrayPartition(x.x[1].^2, x.x[2].^2)
108+
106109
#### testing copyto!
107110
S = [
108111
((1,),(2,)) => ((1,),(2,)),

0 commit comments

Comments
 (0)