-
Notifications
You must be signed in to change notification settings - Fork 63
Bugfix for sequence #73
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,6 +246,7 @@ def save_result_array(self, name, data, group=None, | |
| if not group: | ||
| # Save dataset to results group by default | ||
| group = 'results/' + self.group | ||
|
|
||
| elif not group in h5_file: | ||
| # Create the group if it doesn't exist | ||
| h5_file.create_group(group) | ||
|
|
@@ -422,6 +423,11 @@ def __init__(self, h5_path, run_paths, no_write=False): | |
| run_paths = run_paths['filepath'] | ||
| self.h5_path = h5_path | ||
| self.no_write = no_write | ||
| try: | ||
| h5py.File(h5_path, 'r') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that this may leave an open reference to the h5 file. It would be better to use a context manager like this: Which ensures that the file is closed appropriately. |
||
| except: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is best to catch a specific exception class here. Could you catch the specific exception raised? (Presumably it is |
||
| h5py.File(h5_path,'w') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to previous comment, use of a context manager here would be preferable. Also, you might want to consider using the I think it might also be appropriate to wrap the creation call in a check of the |
||
|
|
||
| if not self.no_write: | ||
| self._create_group_if_not_exists(h5_path, '/', 'results') | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove this unnecessary change so that it doesn't clutter up the diff?