From 35bef1b818321779e6a38bae2ae14485ed749f1d Mon Sep 17 00:00:00 2001 From: Michael Eastwood Date: Sun, 31 Dec 2017 10:08:27 -0800 Subject: [PATCH 1/2] fixes for broadcasting operations like .+= and .= --- src/alm.jl | 1 + src/map.jl | 1 + test/alm.jl | 8 ++++++++ test/map.jl | 7 +++++++ 4 files changed, 17 insertions(+) diff --git a/src/alm.jl b/src/alm.jl index be08580..df49685 100644 --- a/src/alm.jl +++ b/src/alm.jl @@ -288,6 +288,7 @@ Base.:(==)(lhs::Alm, rhs::AbstractVector) = false Base.:(==)(lhs::AbstractVector, rhs::Alm) = false # Custom broadcasting +Base.Broadcast.broadcast_indices(::Type{<:Alm}, alm) = indices(alm) Base.Broadcast._containertype(::Type{<:Alm}) = Alm Base.Broadcast.promote_containertype(::Type{Any}, ::Type{Alm}) = Alm Base.Broadcast.promote_containertype(::Type{Alm}, ::Type{Any}) = Alm diff --git a/src/map.jl b/src/map.jl index 70a0b81..fb6dd25 100644 --- a/src/map.jl +++ b/src/map.jl @@ -303,6 +303,7 @@ Base.:(==)(lhs::HealpixMap, rhs::AbstractVector) = false Base.:(==)(lhs::AbstractVector, rhs::HealpixMap) = false # Custom broadcasting +Base.Broadcast.broadcast_indices(::Type{<:HealpixMap}, map) = indices(map) Base.Broadcast._containertype(::Type{<:RingHealpixMap}) = RingHealpixMap Base.Broadcast._containertype(::Type{<:NestHealpixMap}) = NestHealpixMap Base.Broadcast.promote_containertype(::Type{Any}, ::Type{T}) where {T<:HealpixMap} = T diff --git a/test/alm.jl b/test/alm.jl index 924f367..d87d3e8 100644 --- a/test/alm.jl +++ b/test/alm.jl @@ -154,6 +154,14 @@ @test f.(1, alm, alm) == Alm(lmax, mmax, f.(1, coefficients, coefficients)) @test f.(alm, alm, alm) == Alm(lmax, mmax, f.(coefficients, coefficients, coefficients)) @inferred broadcast(f, alm, alm, alm) + + alm1 = Alm(Complex128, lmax, mmax) + rand!(alm1.coefficients) + alm2 = deepcopy(alm1) + alm1 .+= 1 + @test alm1 == alm2 .+ 1 + alm1 .= sin.(alm1) + @test alm1 == sin.(alm2 .+ 1) end end diff --git a/test/map.jl b/test/map.jl index 301415b..b5d1261 100644 --- a/test/map.jl +++ b/test/map.jl @@ -167,6 +167,13 @@ @test f.(1, map, map) == Map(nside, f.(1, pixels, pixels)) @test f.(map, map, map) == Map(nside, f.(pixels, pixels, pixels)) @inferred broadcast(f, map, map, map) + + map1 = Map(nside, randn(npix)) + map2 = deepcopy(map1) + map1 .+= 1 + @test map1 == map2 .+ 1 + map1 .= sin.(map1) + @test map1 == sin.(map2 .+ 1) end end From 1deac103d5a7aa4bd27f557da310d7239258768b Mon Sep 17 00:00:00 2001 From: Michael Eastwood Date: Sun, 31 Dec 2017 10:09:49 -0800 Subject: [PATCH 2/2] update NEWS.md --- NEWS.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.md b/NEWS.md index bd75a83..1e56f88 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,11 @@ # News +## v0.2.6 + +*unreleased* + +* Bugfix for broadcasting operations like `.+=` and `.=` + ## v0.2.5 *2017-11-13*