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
48 stars 11 forks source link

Pretty printing for `Counts` and `Probabilities` #344

Closed kahaaga closed 6 months ago

kahaaga commented 6 months ago

In #341, I remove the dependency on DimensionalData.jl. The result is that we lose pretty printing of the marginals (outcomes) for Counts and Probabilities. We should implement pretty printing manually here.

kahaaga commented 6 months ago

By modifying the DimensionalData.jl printing code, I'm getting close to something here.

julia> Counts([50, 44, 33], ["cake", "meat", "veggie"])
 Counts{Int64,1} over 3 outcomes
 "cake"    50
 "meat"    44
 "veggie"  33

julia> Counts(rand(1:3, 5, 2))
 5×2 Counts{Int64,2}
                          Outcome(1)  Outcome(2)
 Outcome(1)                        3           1
 Outcome(2)                        3           1
 Outcome(3)                        3           1
 Outcome(4)                        1           1
 Outcome(5)                        3           3

julia> Counts(rand(1:10, 4), ["o1", "o2", 56, 2])
 Counts{Int64,1} over 4 outcomes
   "o1"   5
   "o2"   5
 56       8
  2      10

julia> c = Counts(rand(1:30, 2, 3, 3), (['a', 'e'], 2:2:6, [(1, 2), (2, 1), (3, 1)]))
 2×3×3 Counts{Int64,3}
[:, :, 1]
                 2   4   6
 'a'            15  18  27
 'e'            23  13  17
[and 2 more slices...]

I just need to get rid of the extra spaces that sometimes occur, and I think this is good to go.