Skip to content

Commit

Permalink
ndarray: protect from diving zero for non-inplace op (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
iblislin committed Dec 15, 2017
1 parent 8135a63 commit 1e20f50
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ndarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,11 @@ broadcast_(::typeof(/), x::NDArray, y::NDArray) = _div(x, y)
broadcast_(::typeof(/), x::NDArray, y::Real) = _div_scalar(x, scalar = y)
broadcast_(::typeof(/), y::Real, x::NDArray) = _rdiv_scalar(x, scalar = y)

function broadcast_(::typeof(/), x::NDArray{T}, y::Real) where {T<:Integer}
@assert(round(T, y) != zero(T), "Integer divided by zero")
_div_scalar(x, scalar = y)
end

import Base: %

"""
Expand Down

0 comments on commit 1e20f50

Please sign in to comment.