Skip to content

Commit

Permalink
Fix #364
Browse files Browse the repository at this point in the history
_use_multline_show now tallies the number of numeric entries _only_ for
scalars, tuples of scalars, or vector fields. If any other type of field
is encountered, defaults to multiline show layout.

This change in logic avoids problems with types like
EmpiricalUnivariateDistribution which contain nonnumeric fields.
  • Loading branch information
jiahao committed Apr 22, 2015
1 parent 2348a54 commit b4b2a07
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/show.jl
Expand Up @@ -35,8 +35,9 @@ function _use_multline_show(d::Distribution, pnames)
pv = d.(p)
if !(isa(pv, Number) || isa(pv, NTuple) || isa(pv, AbstractVector))
multline = true
else
tlen += length(pv)
end
tlen += length(pv)
push!(namevals, (p, pv))
end
if tlen > 8
Expand Down

2 comments on commit b4b2a07

@lindahua
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess EmpiricalUnivariateDistribution might deserve a specialized show method.

@jiahao
Copy link
Member Author

@jiahao jiahao commented on b4b2a07 Apr 22, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's also a possibility. The .cdf field could be hidden from users. At the same time, this fix does prevent future logic errors in distribution types that may contain noniterable fields.

Please sign in to comment.