Skip to content

Commit

Permalink
Add broadcast for same-length tuples on 0.5 (#324)
Browse files Browse the repository at this point in the history
Fixes #291
  • Loading branch information
pabloferz authored Feb 12, 2017
1 parent 1edb00f commit b425216
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,11 @@ if VERSION < v"0.5.0-dev+4677"
Base.cholfact!(A::HermOrSym, T::Type) = cholfact!(A.data, Symbol(A.uplo), T)
end

# broadcast over same length tuples, from julia#16986
if v"0.5.0-dev+4002" VERSION < v"0.6.0-dev.693"
Base.Broadcast.broadcast{N}(f, t::NTuple{N}, ts::Vararg{NTuple{N}}) = map(f, t, ts...)
end

# julia#18510
if VERSION < v"0.6.0-dev.826"
_Nullable_field2(x) = !x
Expand Down
8 changes: 7 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,12 @@ f15032(a) = @compat sin.(a)
@inferred f15032([1, 2, 3])
@inferred f15032([1.0, 2.0, 3.0])

# Issue #291
if VERSION v"0.5.0-dev+4002"
@test (1, 2) == @compat abs.((1, -2))
@test broadcast(+, (1.0, 1.0), (0, -2.0)) == (1.0,-1.0)
end

if VERSION v"0.4.0-dev+3732"
@test Symbol("foo") === :foo
@test Symbol("foo", "bar") === :foobar
Expand Down Expand Up @@ -1762,4 +1768,4 @@ end
@compat primitive type Primitive20418{T} <: Ref{T} 16 end
@test !Compat.TypeUtils.isabstract(Primitive20418)
@test isbits(Primitive20418{Int})
@test sizeof(Primitive20418{Int}) == 2
@test sizeof(Primitive20418{Int}) == 2

0 comments on commit b425216

Please sign in to comment.