Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #131 from JuliaStats/patch
Browse files Browse the repository at this point in the history
Fix breakage related to introduction of Base.OneTo
  • Loading branch information
davidagold authored Jul 13, 2016
2 parents e350e40 + 87874c2 commit b412402
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
18 changes: 13 additions & 5 deletions src/broadcast.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
using Base.Broadcast: check_broadcast_shape
using Base: promote_eltype
using Base.Broadcast: check_broadcast_shape, broadcast_shape
using Base.Cartesian

if VERSION >= v"0.5.0-dev+5189"
_to_shape(dims::Base.DimsOrInds) = map(_to_shape, dims)
_to_shape(r::Base.OneTo) = Int(last(r))
else
_to_shape(x) = x
end

if VERSION < v"0.5.0-dev+4724"
function gen_nullcheck(narrays::Int, nd::Int)
e_nullcheck = macroexpand(:( @nref $nd isnull_1 d->j_d_1 ))
Expand All @@ -24,7 +32,7 @@ if VERSION < v"0.5.0-dev+4724"
@nexprs $narrays k->(isnull_k = A_k.isnull)
# check size
@assert ndims(B) == $nd
@ncall $narrays Base.Broadcast.check_broadcast_shape size(B) k->A_k
@ncall $narrays check_broadcast_shape size(B) k->A_k
# main loops
@nloops($nd, i, B,
d->(@nexprs $narrays k->(j_d_k = size(A_k, d) == 1 ? 1 : i_d)), # pre
Expand Down Expand Up @@ -155,8 +163,8 @@ else
@inline function Base.broadcast!(f, Z::NullableArray, Xs::NullableArray...;
lift=false)
nargs = length(Xs)
check_broadcast_shape(indices(Z), Xs...)
sz = size(Z)
check_broadcast_shape(sz, Xs...)
mapindex = map(x->newindexer(sz, x), Xs)
Base.Broadcast._broadcast!(f, Z, mapindex, Xs, Val{nargs}; lift=lift)
Z
Expand All @@ -176,8 +184,8 @@ arguments consisting of both `Array`s and `NullableArray`s will fall back to the
implementation of `broadcast` in `base/broadcast.jl`.
""" ->
@inline function Base.broadcast(f, Xs::NullableArray...;lift::Bool=false)
return broadcast!(f, NullableArray(eltype(Base.promote_eltype(Xs...)),
Base.Broadcast.broadcast_shape(Xs...)),
return broadcast!(f, NullableArray(eltype(promote_eltype(Xs...)),
_to_shape(broadcast_shape(Xs...))),
Xs...; lift=lift)
end

Expand Down
6 changes: 3 additions & 3 deletions src/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ function unsafe_getvalue_notnull(X::NullableArray, I::Int...)
end

if VERSION >= v"0.5.0-dev+4697"
function Base.checkindex(::Type{Bool}, inds::UnitRange, i::Nullable)
function Base.checkindex(::Type{Bool}, inds::AbstractUnitRange, i::Nullable)

This comment has been minimized.

Copy link
@tkelman

tkelman Jul 14, 2016

Contributor

did AbstractUnitRange exist at 4697?

This comment has been minimized.

Copy link
@davidagold

davidagold Jul 14, 2016

Author Contributor

Ooh, good question. I realize now that my thought process by which I convinced myself that it must have was faulty.

How do I convert from a VersionNumber object to a SHA1?

This comment has been minimized.

Copy link
@tkelman

tkelman Jul 14, 2016

Contributor

maybe bisect while running contrib/commit-name.sh? there might be a better way, not sure. and you should usually only run commit-name.sh on merge commits instead of internediate commits inside of pr's, though i guess there's a bisect concern there.

isnull(i) ? throw(NullException()) : checkindex(Bool, inds, get(i))
end

function Base.checkindex{N}(::Type{Bool}, inds::UnitRange, I::NullableArray{Bool, N})
function Base.checkindex{N}(::Type{Bool}, inds::AbstractUnitRange, I::NullableArray{Bool, N})
anynull(I) && throw(NullException())
checkindex(Bool, inds, I.values)
end

function Base.checkindex{T<:Real}(::Type{Bool}, inds::UnitRange, I::NullableArray{T})
function Base.checkindex{T<:Real}(::Type{Bool}, inds::AbstractUnitRange, I::NullableArray{T})
anynull(I) && throw(NullException())
b = true
for i in 1:length(I)
Expand Down

0 comments on commit b412402

Please sign in to comment.