oscar-system / Oscar.jl

A comprehensive open source computer algebra system for computations in algebra, geometry, and number theory.
https://www.oscar-system.org
Other
338 stars 120 forks source link

`labelled_matrix_formatted` prints unwanted (?) newline #3210

Closed joschmitt closed 8 months ago

joschmitt commented 8 months ago

Describe the bug I played around with labelled_matrix_formatted for the printing of Young tableaux and got the impression that it always produces an additional newline at the end.

To Reproduce

julia> mat = [ "1" "2" "3" ; "4" "5" "" ]
2×3 Matrix{String}:
 "1"  "2"  "3"
 "4"  "5"  ""

julia> labelled_matrix_formatted(stdout, mat)
1 2 3
4 5  
   # <- This is what I am taking about.
julia> 
julia> G = symmetric_group(2)
Permutation group of degree 2 and order 2

julia> character_table(G)
Character table of permutation group of degree 2 and order 2

  2  1  1

    1a 2a
 2P 1a 1a

X_1  1 -1
X_2  1  1

   # <- Also here.
julia>

System (please complete the following information):

julia> Oscar.versioninfo(full=true)
OSCAR version 0.15.0-DEV - #partition, 7d8f092eae -- 2024-01-19 13:43:55 +0100
  combining:
    AbstractAlgebra.jl   v0.35.2
    GAP.jl               v0.10.1
    Hecke.jl             v0.24.1 - #master, b76e7e1835 -- 2024-01-18 11:54:01 +0100
    Nemo.jl              v0.39.1
    Polymake.jl          v0.11.10
    Singular.jl          v0.21.2
  building on:
    Antic_jll               v0.201.500+0
    Arb_jll                 v200.2300.0+0
    Calcium_jll             v0.401.100+0
    FLINT_jll               v200.900.7+0
    GAP_jll                 v400.1200.200+7
    Singular_jll            v403.212.1202+0
    libpolymake_julia_jll   v0.11.2+0
    libsingular_julia_jll   v0.40.9+1
    polymake_jll            v400.1100.1+0
See `]st -m` for a full list of dependencies.

Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 20 × 13th Gen Intel(R) Core(TM) i5-13600
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, goldmont)
  Threads: 1 on 20 virtual cores
Environment:
  JULIA_EDITOR = vim
Official https://julialang.org/ release

Additional context I can probably fix this myself, I just wanted to make sure we agree that this is not the desired behaviour. (Other than that I'm a huge fan of this function already now!)

lgoettgens commented 8 months ago

Good catch, this looks wrong

ThomasBreuer commented 8 months ago

I have no problem with changing the behaviour. But why is this wrong? The first example above (mat = [ "1" "2" "3" ; "4" "5" "" ]) also produces an empty line at the end.

I would say that the two empty lines at the end of the character_table(G) output should better be just one empty line. I can fix this in the relevant show method for character tables. The reason for the double newline is that the footer of the table (which is separated from the table by a newline) is empty.

joschmitt commented 8 months ago

In my opinion, labelled_matrix_formatted should not produce a newline at the end because show apparently (?) always adds one. This is why there are TWO newlines after a character table. Overwriting the show of a matrix of strings

julia> function Base.show(io::IO, ::MIME"text/plain", mat::Matrix{String})
             labelled_matrix_formatted(io, mat)
           end

results in

julia> mat = [ "1" "2" "3" ; "4" "5" "" ]
1 2 3
4 5  

julia> 

(So again two newlines.)

lgoettgens commented 8 months ago

When fiddling around with the three shows of OSCAR, we found out the following (no idea where to find the ref):

ThomasBreuer commented 8 months ago

Thanks. I have approved #3213.