Skip to content

Commit

Permalink
Add broadcast for same-length tuples on 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloferz committed Feb 12, 2017
1 parent 58c52dc commit e6200c0
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 @@ -1680,6 +1680,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 @@ -1751,4 +1757,4 @@ end
let x = [1,2,3]
@dotcompat f(x) = x^2
@test f(x) == [1,4,9]
end
end

0 comments on commit e6200c0

Please sign in to comment.