Skip to content

Commit 60235cb

Browse files
authored
Overload map (#83)
* Overload map * v0.8.4
1 parent 01f5d31 commit 60235cb

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "FillArrays"
22
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
3-
version = "0.8.3"
3+
version = "0.8.4"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/FillArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using LinearAlgebra, SparseArrays
44
import Base: size, getindex, setindex!, IndexStyle, checkbounds, convert,
55
+, -, *, /, \, diff, sum, cumsum, maximum, minimum, sort, sort!,
66
any, all, axes, isone, iterate, unique, allunique, permutedims, inv,
7-
copy, vec, setindex!, count, ==, reshape, _throw_dmrs
7+
copy, vec, setindex!, count, ==, reshape, _throw_dmrs, map
88

99
import LinearAlgebra: rank, svdvals!, tril, triu, tril!, triu!, diag, transpose, adjoint, fill!,
1010
norm2, norm1, normInf, normMinusInf, normp

src/fillbroadcast.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### map
2+
3+
map(f::Function, r::AbstractFill) = Fill(f(getindex_value(r)), axes(r))
4+
15

26
### Unary broadcasting
37

test/runtests.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,18 @@ end
536536
end
537537
end
538538

539+
@testset "map" begin
540+
x = Ones(5)
541+
@test map(exp,x) === Fill(exp(1.0),5)
542+
@test map(isone,x) === Fill(true,5)
543+
544+
x = Zeros(5)
545+
@test map(exp,x) === exp.(x)
546+
547+
x = Fill(2,5,3)
548+
@test map(exp,x) === Fill(exp(2),5,3)
549+
end
550+
539551
@testset "Sub-arrays" begin
540552
A = Fill(3.0,5)
541553
@test A[1:3] Fill(3.0,3)

0 commit comments

Comments
 (0)