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

[ENH] - Update default for savefig #258

Merged
merged 2 commits into from Apr 15, 2021
Merged

[ENH] - Update default for savefig #258

merged 2 commits into from Apr 15, 2021

Conversation

TomDonoghue
Copy link
Member

This updates the savefig decorator to default to saving a figure when a file name is given, meaning save_fig does not have to be explicitly passed. The save_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).

Copy link
Member

@ryanhammonds ryanhammonds 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! I confirmed that file_name can include an absolute/relative path. Sorry for the over complicated PR in fooof.

@TomDonoghue
Copy link
Member Author

Thanks for the review! And no worries at all - exploring code ideas is all part of the game, and helps us move towards the solutions we decide to merge :)

@TomDonoghue TomDonoghue merged commit e193fd3 into main Apr 15, 2021
@TomDonoghue TomDonoghue deleted the savep branch April 15, 2021 19:01
@ryanhammonds ryanhammonds mentioned this pull request May 3, 2021
26 tasks
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

2 participants