Skip to content

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

Open
torfjelde wants to merge 2 commits intoJunoLab:masterfrom
torfjelde:tor/respect-displaysize
Open

Adds :displaysize as chunk option and chunks now correctly respect displaysize#433
torfjelde wants to merge 2 commits intoJunoLab:masterfrom
torfjelde:tor/respect-displaysize

Conversation

@torfjelde
Copy link
Copy Markdown
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
Copy Markdown

codecov-commenter commented Aug 1, 2021

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.91%. Comparing base (381de22) to head (919fa4b).
⚠️ Report is 30 commits behind head on master.

Additional details and impacted files
@@            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.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@torfjelde
Copy link
Copy Markdown
Contributor Author

@sebastianpech would you be willing to accept this?

@sebastianpech
Copy link
Copy Markdown
Contributor

I assume that you meant to tag @pfitzseb

@torfjelde
Copy link
Copy Markdown
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.

3 participants