ronisbr / PrettyTables.jl

Print data in formatted tables.
MIT License
404 stars 38 forks source link

Number of rows printed by PrettyTables. #181

Closed bkamins closed 2 years ago

bkamins commented 2 years ago

@ronisbr can you please explain me this behavior?

julia> show(stdout, gdf[1], crop=:both, display_size=(5, 100)) # 4 lines printed
5×3 SubDataFrame
 Row │ x      y      z     
  ⋮  │   ⋮      ⋮      ⋮
             5 rows omitted
julia> show(stdout, gdf[1], crop=:both, display_size=(6, 100)) $ 5 lines printed
5×3 SubDataFrame
 Row │ x      y      z     
     │ Bool   Bool   Bool  
  ⋮  │   ⋮      ⋮      ⋮
             5 rows omitted
julia> show(stdout, gdf[1], crop=:both, display_size=(7, 100)) # 5 lines printed
5×3 SubDataFrame
 Row │ x      y      z     
     │ Bool   Bool   Bool  
  ⋮  │   ⋮      ⋮      ⋮
             5 rows omitted
julia> show(stdout, gdf[1], crop=:both, display_size=(8, 100)) # 6 lines printed
5×3 SubDataFrame
 Row │ x      y      z     
     │ Bool   Bool   Bool  
─────┼─────────────────────
  ⋮  │   ⋮      ⋮      ⋮
             5 rows omitted
julia> show(stdout, gdf[1], crop=:both, display_size=(9, 100)) # 6 lines printed
5×3 SubDataFrame
 Row │ x      y      z     
     │ Bool   Bool   Bool  
─────┼─────────────────────
  ⋮  │   ⋮      ⋮      ⋮
             5 rows omitted
julia> show(stdout, gdf[1], crop=:both, display_size=(10, 100)) # 7 lines printed
5×3 SubDataFrame
 Row │ x      y      z     
     │ Bool   Bool   Bool  
─────┼─────────────────────
   1 │ false  false  false
  ⋮  │   ⋮      ⋮      ⋮
             4 rows omitted
julia> show(stdout, gdf[1], crop=:both, display_size=(11, 100)) # 8 lines printed
5×3 SubDataFrame
 Row │ x      y      z     
     │ Bool   Bool   Bool  
─────┼─────────────────────
   1 │ false  false  false
  ⋮  │   ⋮      ⋮      ⋮
   5 │ false  false  false
             3 rows omitted

What I do not understand is why sometimes when I increase height by 1 I get the same number of lines printed. How is exactly first element of display_size taken into account when calculating number of lines that should be actually printed?

ronisbr commented 2 years ago

Hi @bkamins !

I just cannot reproduce this bug:

julia> show(stdout, df, crop=:both, display_size=(1, 100))
100×3 DataFrame
 Row │ x1       x2       x3
     │ Float64  Float64  Float64
  ⋮  │    ⋮        ⋮        ⋮
                 100 rows omitted
julia> show(stdout, df, crop=:both, display_size=(2, 100))
100×3 DataFrame
 Row │ x1       x2       x3
     │ Float64  Float64  Float64
  ⋮  │    ⋮        ⋮        ⋮
                 100 rows omitted
julia> show(stdout, df, crop=:both, display_size=(3, 100))
100×3 DataFrame
 Row │ x1        x2        x3
     │ Float64   Float64   Float64
  ⋮  │    ⋮         ⋮         ⋮
                    100 rows omitted
julia> show(stdout, df, crop=:both, display_size=(4, 100))
100×3 DataFrame
 Row │ x1        x2        x3
     │ Float64   Float64   Float64
  ⋮  │    ⋮         ⋮         ⋮
                    100 rows omitted
julia> show(stdout, df, crop=:both, display_size=(5, 100))
100×3 DataFrame
 Row │ x1        x2        x3
     │ Float64   Float64   Float64
  ⋮  │    ⋮         ⋮         ⋮
                    100 rows omitted
julia> show(stdout, df, crop=:both, display_size=(6, 100))
100×3 DataFrame
 Row │ x1        x2         x3
     │ Float64   Float64    Float64
  ⋮  │    ⋮          ⋮          ⋮
                      100 rows omitted
julia> show(stdout, df, crop=:both, display_size=(7, 100))
100×3 DataFrame
 Row │ x1        x2         x3
     │ Float64   Float64    Float64
  ⋮  │    ⋮          ⋮          ⋮
                      100 rows omitted
julia> show(stdout, df, crop=:both, display_size=(8, 100))
100×3 DataFrame
 Row │ x1        x2         x3
     │ Float64   Float64    Float64
  ⋮  │    ⋮          ⋮          ⋮
                      100 rows omitted
julia> show(stdout, df, crop=:both, display_size=(9, 100))
100×3 DataFrame
 Row │ x1         x2         x3
     │ Float64    Float64    Float64
─────┼─────────────────────────────────
  ⋮  │     ⋮          ⋮          ⋮
                       100 rows omitted
julia> show(stdout, df, crop=:both, display_size=(10, 100))
100×3 DataFrame
 Row │ x1         x2         x3
     │ Float64    Float64    Float64
─────┼─────────────────────────────────
   1 │ 0.218312   0.702555   0.340554
  ⋮  │     ⋮          ⋮          ⋮
                        99 rows omitted
julia> show(stdout, df, crop=:both, display_size=(11, 100))
100×3 DataFrame
 Row │ x1         x2         x3
     │ Float64    Float64    Float64
─────┼─────────────────────────────────
   1 │ 0.218312   0.702555   0.340554
  ⋮  │     ⋮          ⋮          ⋮
 100 │ 0.690223   0.23945    0.106599
                        98 rows omitted

Are you sure you are using PrettyTables v2.1.1? I fixed a printing bug similar to this in the last version.

bkamins commented 2 years ago

Ah - I was on v2.1.0 - all is good. Thank you!