QuantumClifford.jl icon indicating copy to clipboard operation
QuantumClifford.jl copied to clipboard

Do not print out gigantic tableaux

Open Krastanov opened this issue 2 years ago • 2 comments

Modify show so that too large tableaux do not pollute the CLI

Krastanov avatar Mar 11 '22 05:03 Krastanov

same for PauliOps and CliffordOps

Krastanov avatar Mar 11 '22 05:03 Krastanov

this could be a useful inspiration (the code used for printing arrays in julia): https://github.com/JuliaLang/julia/blob/9028130434c5fb55e00c65e73aaf13cf0afde380/base/arrayshow.jl

Krastanov avatar Mar 21 '22 06:03 Krastanov

how do we define "too large"? Will there be a config that the user can set? (like the way "pandas" module in python skips middle row/column there are too many of them).

Shayan-P avatar Mar 31 '23 02:03 Shayan-P

Reusing some of the tools in LinearAlgebra for printing out arrays is probably the best ways to do it. If the tools are private to the module and not guaranteed to remain stable, then some inspiration from them could still be useful.

  • The show method for arrays detects how large the terminal is and prints dots if necessary to skip rows (e.g., see the result of rand(100,100))
  • The show method checks for the "compact" hint and prints even shorter representation of arrays in such case (e.g., see the result of [rand(100)])
  • The show method for sparse matrices is even fancier: if the matrix is large, it prints a "unicode" plot of where the non-zero elements are

The tableaux printing can be improved along the same lines.

Krastanov avatar Mar 31 '23 04:03 Krastanov