JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.69k stars 5.48k forks source link

ConsoleLogger limits printed matrix precision despite show_limited = false #34592

Open tpapp opened 4 years ago

tpapp commented 4 years ago
julia> versioninfo()
Julia Version 1.5.0-DEV.204
Commit 529b3655ad (2020-01-30 07:59 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 1
  JULIA_CMDSTAN_HOME = /home/tamas/src/cmdstan/

julia> using Logging

julia> A = fill(Float64(π), 3, 3)
3×3 Array{Float64,2}:
 3.14159  3.14159  3.14159
 3.14159  3.14159  3.14159
 3.14159  3.14159  3.14159

julia> b = fill(Float64(π), 3)
3-element Array{Float64,1}:
 3.141592653589793
 3.141592653589793
 3.141592653589793

julia> global_logger(ConsoleLogger(stdout, Logging.Debug; show_limited = false))
Base.CoreLogging.SimpleLogger(Base.TTY(RawFD(0x0000000d) open, 0 bytes waiting), Debug, Dict{Any,Int64}())

julia> @info "info" A = A b = b
┌ Info: info
│   A =
│    3×3 Array{Float64,2}:
│     3.14159  3.14159  3.14159
│     3.14159  3.14159  3.14159
│     3.14159  3.14159  3.14159
│   b =
│    3-element Array{Float64,1}:
│     3.141592653589793
│     3.141592653589793
└     3.141592653589793

julia> global_logger(SimpleLogger(stdout, Logging.Debug))
ConsoleLogger(Base.TTY(RawFD(0x0000000d) open, 0 bytes waiting), Debug, Logging.default_metafmt, false, 0, Dict{Any,Int64}())

julia> @info "info" A = A  b = b
┌ Info: info
│   A = [3.141592653589793 3.141592653589793 3.141592653589793; 3.141592653589793 3.141592653589793 3.141592653589793; 3.141592653589793 3.141592653589793 3.141592653589793]
│   b = [3.141592653589793, 3.141592653589793, 3.141592653589793]
└ @ Main REPL[28]:1
JeffBezanson commented 4 years ago

Precision is controlled by :compact, not :limit.

tpapp commented 4 years ago

That's a fair point, but I am puzzled because I would expect that arrays and vectors would print the same.

julia> show(IOContext(stdout, :limit => false, :compact => true), fill(Float64(π), 3, 3))
[3.14159 3.14159 3.14159; 3.14159 3.14159 3.14159; 3.14159 3.14159 3.14159]
julia> show(IOContext(stdout, :limit => false, :compact => true), fill(Float64(π), 3))
[3.14159, 3.14159, 3.14159]