8000 Add overwrite keyword to write_map by keskitalo · Pull Request #386 · healpy/healpy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add overwrite keyword to write_map #386

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

Merged
merged 3 commits into from
Apr 14, 2017
Merged

Conversation

keskitalo
Copy link
Contributor

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.

@lpsinger
8000 Copy link
Member

This matches the behavior of Astropy's HDUList.writeto and Table.writeto methods.

But due to the change in the default behavior, you should document this in the changelog.

@keskitalo
Copy link
Contributor Author

I added the current release candidate to the changelog and made a note about the change in default behaviour. Thanks for the links to astropy, I didn't realize the type of the error was different for Python 2/3.

@keskitalo
Copy link
Contributor Author

Turns out the January modification caused a healpy write_map unit test to fail when called repeatedly. I modified the test to use the new "overwrite" keyword.

@zonca
Copy link
Member
zonca commented Apr 14, 2017

thanks!

@zonca zonca merged commit ebe96df into healpy:master Apr 14, 2017
@keskitalo keskitalo deleted the overwrite branch April 14, 2017 05:04
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
0