Skip to content

Commit

Permalink
Remove _isapprox hack (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
devmotion authored Sep 24, 2020
1 parent 09ea3e7 commit 2d566ae
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"
[compat]
Adapt = "2"
ChainRules = "0.7"
ChainRulesCore = "0.9.7"
ChainRulesCore = "0.9.9"
Compat = "3.6"
DiffRules = "0.1, 1.0"
Distributions = "0.23.3"
Expand Down
7 changes: 1 addition & 6 deletions src/univariate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,10 @@ end
function TuringPoissonBinomial(p::AbstractArray{<:Real}; check_args = true)
pb = Distributions.poissonbinomial_pdf_fft(p)
ϵ = eps(eltype(pb))
check_args && @assert all(x -> x >= -ϵ, pb) && _isapprox(sum(pb), 1, ϵ)
check_args && @assert all(x -> x >= -ϵ, pb) && isapprox(sum(pb), 1; atol=ϵ)
return TuringPoissonBinomial(p, pb)
end

# @non_differentiable cannot deal with kwargs.
# This circumvents the kwarg in `isapprox` in the constructor above
_isapprox(x,y,atol) = isapprox(x,y,atol=atol)
@non_differentiable _isapprox(::Any,::Any,::Any)

function logpdf(d::TuringPoissonBinomial{T}, k::Int) where T<:Real
insupport(d, k) ? log(d.pmf[k + 1]) : -T(Inf)
end
Expand Down

0 comments on commit 2d566ae

Please sign in to comment.