Add overwrite keyword to write_map #386
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.
Changes to fitsfunc.py in 4438558 caused a change in write_map() behavior. Prior, trying to write to a file that already existed caused the file to be silently overwritten.
After the change, write_map throws an IOError when the user attempts to write to an existing file. The only way to avoid the error is to check for the file existence and remove it before write_map().
It seems unnecessary to require users to check file existence every time they write a map. This pull request implements a keyword argument to write_map() called "overwrite". The current default behavior (fail when file exists) can be retained by setting overwrite=False by default. Defaulting it to True would restore the old default behavior and not require packages that depend on Healpy to be changed everywhere write_map() is called. Either way, user can choose to overwrite existing files without explicitly checking their existence.