Skip to content

Commit

Permalink
Merge pull request #1193 from nalimilan/patch-1
Browse files Browse the repository at this point in the history
Fix test failure in discretize_make_ia
  • Loading branch information
bjarthur authored Sep 14, 2018
2 parents f963564 + 845c880 commit e55dee9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,11 @@ function trim_zip(xs...)
end

# Convenience constructors of IndirectArrays
discretize_make_ia(values::AbstractVector, levels) = IndirectArray(indexin(values, levels), levels)
function discretize_make_ia(values::AbstractVector, levels)
index = something.(indexin(values, levels), 0)
any(iszero, index) && throw(ArgumentError("values not in levels encountered"))
IndirectArray(index, levels)
end
discretize_make_ia(values::AbstractVector) = discretize_make_ia(values, unique(values))
discretize_make_ia(values::AbstractVector, ::Nothing) = discretize_make_ia(values)

Expand Down

0 comments on commit e55dee9

Please sign in to comment.