[ENH] - Update default for savefig #258
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This updates the
savefig
decorator to default to saving a figure when a file name is given, meaningsave_fig
does not have to be explicitly passed. Thesave_fig
input can still be explicitly passed to stop the figure from saving.Following this update, this will now save:
example_plot(file_path=TEST_PLOTS_PATH, file_name='test_savefig1.pdf')
This will now not save:
example_plot(save_fig=False, file_path=TEST_PLOTS_PATH, file_name='test_savefig3.pdf')
^This might seem like a slightly weird construct, but it's something I use a fair amount - to define the name I need, but use a general setting to define when I actually save things.
This PR also updates the tests, generalizing them to check this new behaviour. It also moves away from using tempfile for these particular files, since that doesn't work well in this case (since the tempfiles are defined, the path check passes whether or not the figure file is saved).