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
Make pyedr also return a dictionary of units #56
Conversation
Codecov ReportBase: 89.21% // Head: 89.70% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #56 +/- ##
==========================================
+ Coverage 89.21% 89.70% +0.49%
==========================================
Files 7 7
Lines 482 505 +23
==========================================
+ Hits 430 453 +23
Misses 52 52
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
I have updated this now so the units are also returned through panedr, not just pyedr |
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.
Looks good to me @BFedder :)
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.
Add example of units in the readme please ?
Having looked at the code again to add an example for the readme, I have realised that having the energy dict as part of the return value for |
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.
I like the change to a separate method. Looks good to me!
@IAlibay do you have any blocking concerns here? Otherwise I will merge so we can progress on MDAnalysis/mdanalysis#3749 |
I'll re-review later today, MDA release comes as a priority. |
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.
I think get_unit_dict()
does too much work — it seems it reads the whole file. Maybe I misunderstood how it works, though, then ignore.
Please also fix PEP8 complaints.
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.
LGTM :)
@IAlibay any outstanding comments or can I merge? :) |
I'll review in a few |
(EDR_BLOCKS, EDR_BLOCKS_XVG), | ||
(Path(EDR), EDR_XVG),]) | ||
params=[(EDR, EDR_XVG, EDR_UNITS), | ||
(EDR_IRREG, EDR_IRREG_XVG, EDR_IRREG_UNITS), |
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.
I'll let it go here because the likelihood is that no one was using these downstream, but arbitrarily renaming file object names like this is a breaking change, please avoid doing this.
pyedr/pyedr/pyedr.py
Outdated
return unit_dict | ||
|
||
|
||
def edr_to_dict(path: str, verbose: bool = False) -> (Dict[str, np.ndarray], |
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.
I'm not sure I understand what's going on with this PR, didn't you say that you wanted to not return a tuple here, and therefore added get_unit_dictionary
, but this is still happening?
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.
I really need to stop changing code without changing the documentation to match it..... thanks!
pyedr/pyedr/pyedr.py
Outdated
@@ -436,6 +439,8 @@ def read_edr(path: str, verbose: bool = False) -> read_edr_return_type: | |||
A list containing the names of the energy terms found in the file | |||
times: list[float] | |||
A list containing the time of each step/frame. | |||
unit_dict: Dict[str, str] |
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.
This is not in the return signature?
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.
Thanks @BFedder lgtm!
def test_output_type(self, edr): | ||
""" | ||
Test that the function returns a dictionary of ndarrays | ||
""" | ||
assert isinstance(edr.edr_dict, dict) | ||
assert isinstance(edr.edr_dict['Time'], np.ndarray) | ||
|
||
def test_units(self, edr): |
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.
The class name doesn't really match what this is doing, but I don't think it's worth being pedantic about it.
Are the settings on this repo that new commits dismiss reviews automatically? Is this desired? @hmacdope @IAlibay @jbarnoud @BFedder Personally, this looks like generating too much work. I am unlikely to go back to a PR if I approved it because this means (to me at least) that all the things I cared about had been addressed. I suggest to change the settings. |
I don't dismiss the reviews on purpose at least (and I also find that "dismissed stale reviews" sounds a bit harsh), so I hope it happens automatically rather than by some mistake I might make. I agree with you - this should not happen automatically I think. If there are big changes still, a new review could always be requested. |
@orbeckst that might be me just using default settings when I set up branch protection. This is fixed now. I assume by this that we're ok to merge? |
Following the discussion on units on PR 3749, I have changed pyedr here so it returns a dictionary of the units it reads from the EDR file as well.