quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.92k stars 322 forks source link

Limiting table size with quarto using Julia #6897

Closed ymer closed 11 months ago

ymer commented 1 year ago

Bug description

If I run pretty_table(df, display_size = (50, 50)) this displays only a limited part of the large dataframe df.

However, if I quarto render this inside a julia block in a .qmd file, the resulting html file has no limitations on the table size.

Steps to reproduce

No response

Expected behavior

No response

Actual behavior

No response

Your environment

Quarto check output

[✓] Checking versions of quarto binary dependencies... Pandoc version 3.1.1: OK Dart Sass version 1.55.0: OK [✓] Checking versions of quarto dependencies......OK [✓] Checking Quarto installation......OK Version: 1.3.450 Path: /Applications/quarto/bin

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK Version: 3.9.13 (Conda) Path: /opt/homebrew/anaconda3/bin/python Jupyter: 4.11.1 Kernels: julia-1.8, python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK Version: 4.2.2 Path: /Library/Frameworks/R.framework/Resources LibPaths:

[✓] Checking Knitr engine render......OK

mcanouil commented 1 year ago

Thanks for the report!

Could you properly fill the issue with the requested information as we do need them in order to understand and possibly fix the issue? Could you share a small self-contained "working" (reproducible) example to work with, i.e., a complete Quarto document or a Git repository? Thanks.

You can share a Quarto document using the following syntax, i.e., using more backticks than you have in your document (usually four ````).

````qmd
---
title: "Reproducible Quarto Document"
format: html
---

This is a reproducible Quarto document using `format: html`.
It is written in Markdown and contains embedded R code.
When you run the code, it will produce a plot.

```{r}
plot(cars)

The end.

ymer commented 1 year ago
---
title: "Reproducible Quarto Document"
format: html
---

This is a reproducible Quarto document using `format: html`.
It is written in Markdown and contains embedded Julia code.
When you render the code, it will produce too large a table.

```{julia}
using DataFrames, PrettyTables

n = 1000
df = DataFrame(A = rand(n), B = rand(n), C = rand(n))
pretty_table(df, header = names(df), display_size = (50, 50))

The end.

mcanouil commented 1 year ago

Also the output of quarto check as initially requested in the issue template, please.

cderv commented 1 year ago

@ymer from the doc at https://ronisbr.github.io/PrettyTables.jl/stable/lib/library/#PrettyTables.pretty_table-Tuple{Any}

display_size::Tuple{Int, Int}: A tuple of two integers that defines the display size (num. of rows, num. of columns) that is available to print the table. It is used to crop the data depending on the value of the keyword crop. Notice that if a dimension is not positive, then it will be treated as unlimited. (Default = displaysize(io))

You did not set crop

crop::Symbol: Select the printing behavior when the data is bigger than the available display size (see display_size). It can be :both to crop on vertical and horizontal direction, :horizontal to crop only on horizontal direction, :vertical to crop only on vertical direction, or :none to do not crop the data at all. If the io has :limit => true, then crop is set to :both by default. Otherwise, it is set to :none by default.

I understand that the default IO here has set crop = :none. If you set crop = :both, you'll see the effect of your display size for the text output. display_size and crop are for text backend output.

---
title: "Reproducible Quarto Document"
format: html
---

This is a reproducible Quarto document using `format: html`.
It is written in Markdown and contains embedded Julia code.
When you render the code, it will produce too large a table.

```{julia}
using DataFrames, PrettyTables

n = 1000
df = DataFrame(A = rand(n), B = rand(n), C = rand(n))
pretty_table(df, header = names(df), display_size = (10, 50), crop = :both)

The end.



![image](https://github.com/quarto-dev/quarto-cli/assets/6791940/297e50e1-13df-48ca-803b-cf5a8347bd84)
dragonstyle commented 11 months ago

Based on the latest message here, this looks like we can safely close this. Please feel free to re-open if it seems there is something we should look more closely at.