Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds :displaysize as chunk option and chunks now correctly respect displaysize #433

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

torfjelde
Copy link
Contributor

@torfjelde torfjelde commented Aug 1, 2021

AFAIK there's not a good way of setting the displaysize for IO instances in Weave.jl. In particular this leads to issues when outputting tables, e.g. #200. The issue is made more confusing by the fact that we have a :line_width chunk option which specifies the number of columns before we wrap the lines, not truncate, and so even if you try to do

withenv("COLUMNS" => 200) do
    ...
end

within a notebook, you still end up with wrapped output even though now the truncation is okay.

So, this PR makes the following changes:

  1. All chunks are evaluated with the default displaysize. This is equivalent to the current behavior since as of right now we simply set :limit => true and thus implicitly :displaysize => displaysize() introduced in limit display: #311.
  2. Allow further specification of displaysize as a chunk option. This addresses all the annoyances with truncated tables, etc. + naturally follows the same behavior as you'd expect from IO.
  3. Disable wrap by default since it's utility is somewhat limited due to the limit display: #311 + the default value of :line_width is actually lower than the default displaysize()[2] (which is 80), hence we end up wrapping lines that "shouldn't" be wrapped according to default settings in Julia (most other packages will display according to displaysize so most outputs will take advantage of 80 cols if need be).

I'll add docs too once I get the thumbs up that this is a good idea from ya'll :)

EDIT: Added tests.

@codecov-commenter
Copy link

codecov-commenter commented Aug 1, 2021

Codecov Report

Merging #433 (919fa4b) into master (381de22) will decrease coverage by 1.14%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #433      +/-   ##
==========================================
- Coverage   74.05%   72.91%   -1.15%     
==========================================
  Files          26       26              
  Lines        1353     1355       +2     
==========================================
- Hits         1002      988      -14     
- Misses        351      367      +16     
Flag Coverage Δ
unittests 72.91% <100.00%> (-1.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/config.jl 20.00% <ø> (ø)
src/run.jl 84.42% <100.00%> (+0.12%) ⬆️
src/rendering/common.jl 69.87% <0.00%> (-19.28%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 381de22...919fa4b. Read the comment docs.

@torfjelde
Copy link
Contributor Author

@sebastianpech would you be willing to accept this?

@sebastianpech
Copy link
Contributor

I assume that you meant to tag @pfitzseb

@torfjelde
Copy link
Contributor Author

Haha, yes; sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants