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

issue with fig.keep: don't try to remove figures if all should be kept #1955

Merged
merged 9 commits into from
Feb 9, 2021

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Jan 28, 2021

when using fig.keep with index vector it could happen. This should fix #1579

I took the opportunity of this PR to

  1. Refactor a bit with a new internal function rearrange_figs() to apply then logic previously in block_exec()
  2. Add some unit tests thanks to this new function
  3. Change the style of the other tests

About the unit test, it took me some times to understand the plot logic with recorderplot and low level plot. I believe I got it right, but you set in the start of the test file

op = options(device = function(file = NULL, ...) {
  pdf(file, ...)
  dev.control('enable')  # important! otherwise plots get discarded
})

which is unset with options(op) a bit after

So I am unsure if I can use plot functions below this. It seems to work though.

Last step would have been a refactoring between files as I think it could be interested to have all the plot related function in a file plot.R like the test files.

That is for another time.

Copy link
Owner

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

@yihui yihui merged commit 9b8e732 into master Feb 9, 2021
@yihui yihui deleted the fig-keep-index branch February 9, 2021 19:44
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fig.keep=3 suppresses code and output for markdown chunk
2 participants