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

Allow load_icgem_gdf to take open file objects #155

Merged
merged 1 commit into from Mar 9, 2020
Merged

Conversation

leouieda
Copy link
Member

@leouieda leouieda commented Mar 8, 2020

Previously just assumed fname was a string and called open on it.
Now, check if it's a file-like object (has a read method) and don't
open it if that's the case. Use contextlib to keep the with
statement in case we do have to open the file. This is useful if the
file is compressed and can be opened with bz2.open, gzip.open, etc
before passing on to the function.

Reminders:

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst and the base __init__.py file for the package.
  • Write detailed docstrings for all functions/classes/methods. It often helps to design better code if you write the docstrings first.
  • If adding new functionality, add an example to the docstring, gallery, and/or tutorials.
  • Add your full name, affiliation, and ORCID (optional) to the AUTHORS.md file (if you haven't already) in case you'd like to be listed as an author on the Zenodo archive of the next release.

Previously just assumed `fname` was a string and called `open` on it.
Now, check if it's a file-like object (has a `read` method) and don't
open it if that's the case. Use `contextlib` to keep the `with`
statement in case we do have to open the file. This is useful if the
file is compressed and can be opened with `bz2.open`, `gzip.open`, etc
before passing on to the function.
@leouieda leouieda requested a review from santisoler March 8, 2020 19:10
@leouieda leouieda merged commit 5f19f5e into master Mar 9, 2020
@leouieda leouieda deleted the load_gdf_file branch March 9, 2020 18:43
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