Skip to content

Commit

Permalink
use throw(ArgumentError) instead of error in distribution constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
lindahua committed Aug 2, 2015
1 parent 86335b1 commit 42b4ea5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/univariate/continuous/arcsine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ immutable Arcsine <: ContinuousUnivariateDistribution
b::Float64

function Arcsine(a::Float64, b::Float64)
a < b || throw(ArgumentError("a must be less than b."))
a < b || throw(ArgumentError("Arcsine: a must be less than b."))
new(a, b)
end

Expand Down
2 changes: 1 addition & 1 deletion src/univariate/continuous/beta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ immutable Beta <: ContinuousUnivariateDistribution

function Beta::Real, β::Real)
> zero(α) && β > zero(β)) ||
throw(ArgumentError("α and β must be positive"))
throw(ArgumentError("Beta: α and β must be positive"))
@compat new(Float64(α), Float64(β))
end

Expand Down
3 changes: 2 additions & 1 deletion src/univariate/continuous/betaprime.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ immutable BetaPrime <: ContinuousUnivariateDistribution
β::Float64

function BetaPrime::Float64, β::Float64)
> zero(α) && β > zero(β)) || error("α and β must be positive")
> zero(α) && β > zero(β)) ||
throw(ArgumentError("BetaPrime: α and β must be positive."))
@compat new(Float64(α), Float64(β))
end

Expand Down
3 changes: 2 additions & 1 deletion src/univariate/continuous/biweight.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ immutable Biweight <: ContinuousUnivariateDistribution
σ::Float64

function Biweight::Real, σ::Real)
σ > zero(σ) || throw(ArgumentError("scale must be positive"))
σ > zero(σ) ||
throw(ArgumentError("Biweight: σ must be positive."))
@compat new(Float64(μ), Float64(σ))
end

Expand Down
3 changes: 2 additions & 1 deletion src/univariate/continuous/cauchy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ immutable Cauchy <: ContinuousUnivariateDistribution
σ::Float64

function Cauchy::Real, σ::Real)
σ > zero(σ) || error("Cauchy: scale must be positive")
σ > zero(σ) ||
throw(ArgumentError("Cauchy: σ must be positive."))
@compat new(Float64(μ), Float64(σ))
end

Expand Down

0 comments on commit 42b4ea5

Please sign in to comment.