JuliaDynamics / ComplexityMeasures.jl

Estimators for probabilities, entropies, and other complexity measures derived from data in the context of nonlinear dynamics and complex systems
MIT License
56 stars 14 forks source link

Nicer default printing for estimators and other types #286

Closed kahaaga closed 8 months ago

kahaaga commented 1 year ago

Estimators and other types need nicer default printing. Most of our types are parameterized, often with multiple type parameters, leading to extremely long and messy printing in the console. It would be nice to clean this up a bit.

Example:

julia> s = StatisticalComplexity()
StatisticalComplexity{MLE{SymbolicPermutation{3, typeof(ComplexityMeasures.isless_rand)}}, Distances.JSDivergence, Renyi{Float64, Float64}}(Distances.JSDivergence(), MLE{SymbolicPermutation{3, typeof(ComplexityMeasures.isless_rand)}}(SymbolicPermutation{3, typeof(ComplexityMeasures.isless_rand)}(OrdinalPatternEncoding{3, typeof(ComplexityMeasures.isless_rand)}([0, 0, 0], ComplexityMeasures.isless_rand), 1)), Renyi{Float64, Float64}(1.0, 2.0), Base.RefValue{Float64}(0.0))

It would be nice if this just printed something like

julia> s = StatisticalComplexity()
StatisticalComplexity(probest=MLE{SymbolicPermutation}, dist=Distances.JSDivergence, entr = Renyi)

I'm not sure what level of abstraction default printing should have. But I think a clean-up, all the way from the information measure definitions, all the way up to nested types such as StatisticalComplexity is in order.

Datseris commented 1 year ago

we could define a show method for all top level abstract types that shows the fields and values. We can make the arbitrary decision that for some types we print the actual types, while for all other types we print the type name.

X with fields:
  a = 0.5 # print value
  b = Renyi  # print type, $(nameof(typeof(value))
kahaaga commented 1 year ago

we could define a show method for all top level abstract types that shows the fields and values.

I guess using fieldnames(x::AbstractType) could be used to iterate through all fields and show them.