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

Update ValenceDict #1185

Merged
merged 8 commits into from
Jul 29, 2022
Merged

Update ValenceDict #1185

merged 8 commits into from
Jul 29, 2022

Conversation

lilyminium
Copy link
Collaborator

@lilyminium lilyminium commented Jan 30, 2022

Fixes #1183

@codecov
Copy link

codecov bot commented Jan 30, 2022

Codecov Report

Merging #1185 (f50cd77) into 0-10-x (97462b8) will increase coverage by 0.18%.
The diff coverage is 100.00%.

@lilyminium lilyminium force-pushed the refactor-valence-dict branch from e50d2b1 to d6a8322 Compare January 31, 2022 23:34
j-wags
j-wags previously approved these changes Feb 10, 2022
Copy link
Member

@j-wags j-wags left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool - Thanks @lilyminium! I left some comments, but none are blocking, so this is good to merge as-is. Though if you have time it'd be great to also make similar classmethod/staticmethod changes in ImproperDict.index_of (no need for me to re-review after that, you can merge those changes directly). But since static and class methods are so similar, that's not blocking to merging this PR.

The releasenotes look good. I kinda waffled on whether these are API breaking changes, but I don't think static <--> classmethod changes need to be reported, so they should be in good shape.

Also, super nice tests - I'm still confused how the valencedict ordering problem never got caught, but I'm glad that this PR puts in tests to ensure they remain well behaved!

permutations = OrderedDict(
{
(refkey[0], refkey[1], refkey[2], refkey[3]): 0,
(refkey[3], refkey[1], refkey[2], refkey[0]): 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching the issue with this line in #1183. I've spent a while thinking of how this could possibly be correct and am pulling a blank. So I agree with you and @trevorgokey that it's a bug. I'm wondering how this has never come up, or if it was making trouble in production and never got caught.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method may not be used anywhere, to be honest. If you grep index_of the only instances seem to be associated with VirtualSites, which either uses and ImproperDict or the virtual site one.

Comment on lines -97 to -100
# Ensure key is a tuple.
key = tuple(key)
assert len(key) > 0 and len(key) < 5, "Valence keys must be at most 4 atoms"
# Reverse the key if the first element is bigger than the last.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(not blocking) This PR opts to delete a lot of comments, a few of which are indeed incorrect, but many of which are correct-but-only-marginally-useful. In the future I'd kinda appreciate having fewer marginally-useful comments removed.

Copy link
Collaborator Author

@lilyminium lilyminium Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was always taught not to have low-level comments that are immediately obvious from the nearby code, like Ensure key is a tuple for tuple(key)-- both because they introduce unneeded clutter and because they easily go out of date when the code is changed. I thought about leaving some of the comments in the "im/possible" section but then it seemed that most of them were covered in the docstring or associated error messages.

@mattwthompson
Copy link
Member

Is there anything blocking this from being merged?

@j-wags j-wags changed the base branch from master to main July 29, 2022 20:11
@j-wags j-wags dismissed their stale review July 29, 2022 20:11

The base branch was changed.

@j-wags j-wags changed the base branch from main to 0-10-x July 29, 2022 20:11
@j-wags j-wags merged commit 7b7489c into 0-10-x Jul 29, 2022
@j-wags j-wags deleted the refactor-valence-dict branch July 29, 2022 21:23
j-wags added a commit that referenced this pull request Jul 29, 2022
* update ValenceDict

* blacken

* update changelog

* reformat improperdict too

Co-authored-by: Jeff Wagner <jwagnerjpl@gmail.com>
j-wags added a commit that referenced this pull request Jul 29, 2022
* update ValenceDict

* blacken

* update changelog

* reformat improperdict too

Co-authored-by: Jeff Wagner <jwagnerjpl@gmail.com>

Co-authored-by: Lily Wang <31115101+lilyminium@users.noreply.github.com>
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.

Remove length check in ValenceDict
3 participants