Remove length check in ValenceDict
See original GitHub issueIs your feature request related to a problem? Please describe.
ValenceDict has a number of restrictions that require the length of the key to be no more than 4 atoms. Is there a real reason for this?
Describe the solution you’d like
Remove length check here:
Refactor this to just take the forward or backward permutation. Also, it’s much more idiomatic python to make this a classmethod instead of a staticmethod that uses __class__
.
permutations = OrderedDict({refkey: 0, refkey[::-1]:1})
Describe alternatives you’ve considered
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Remove characters in string when it reaches specific length
And I am checking the whole "Name" value is greater than 255 and if so, Need to remove that extra characters from DisplayName...
Read more >String length - JavaScript - MDN Web Docs - Mozilla
The length data property of a string contains the length of the string in UTF-16 code units.
Read more >String Functions
Returns the rightmost len characters of c1. Trailing blanks are not removed first. If c1 is a fixed-length character string, the result is...
Read more >LEN function - Amazon Redshift - AWS Documentation
Returns the length of the specified string as the number of characters.
Read more >JavaScript String length Property - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Gotcha, I see some points on both sides but ultimately I agree with @lilyminium on all proposed changes here.
This is sorta related to a legacy of rough edges around vsites, which came to be because, when @trevorgokey and I were working on it, vsites were supposed to take like a month, and then at the 6 month point, when crazy edge cases kept popping up, and we had unilaterally made changes to the SMIRNOFF spec, and @trevorgokey had rewritten everything several times, we finally said “this is good enough”, and this got out with some rough edges. So thanks to both of you for the great discussion, I think @lilyminium’s correct-er on every point (except I’m giving up on trying to understand the serialization thing, so I have no opinion there)
I’ve approved the PR that will close this issue.
ValenceDict and ImproperDict both have staticmethods that use
__class__
, so I felt my example was more representative. Again, I have nothing against staticmethods for the reasons you’ve mentioned – they’re a useful construct and exist for a reason. I just think that when you require the class in the method, you should switch to a classmethod to communicate the code more clearly.https://github.com/openforcefield/openff-toolkit/blob/c32527bbdd98e5141c0f7a98c968bf0e514217b0/openff/toolkit/topology/topology.py#L129