[Deprecation] Correct cases for memory units in core.units and fix unit_type detection of FloatWithUnit.from_str#3838
Merged
shyuep merged 27 commits intoJun 17, 2024
Conversation
core.units
DanielYang59
commented
May 18, 2024
core.unitscore.units
Contributor
Author
|
@shyuep Can I have your advice on this please? This should be very similar to the change to |
core.unitscore.units and fix unit_type detection of FloatWithUnit.from_str
Contributor
Author
Member
|
This is fine. I am enabling auto-merge. There was a failing test that needs to be fixed. |
Contributor
Author
|
Thanks. I notice that too e572d34#r143073539, perhaps we also want to rename the |
Member
|
Thanks. I renamed id to id_ |
Contributor
Author
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
core.unitsto fix Incorrect letter cases for memory incore.units#3833FloatWithUnit.from_strto correctly detectunit_typefrom string with space between the value and the unitCorrect cases for memory units in
core.unitsI assume this is another breaking fix, so I marked the incorrect units as deprecated until
2025-01-01. Any suggestion would be appreciated.Currently the case of
byteis incorrect incore.units, whereBrefers to "byte" andbrefers to "bit".Also note
1 byte = 8 bitso we cannot use them interchangeably.pymatgen/pymatgen/core/units.py
Lines 77 to 83 in bb68c78
Case sensitivity for memory units
I assume there is no good reason to remove case sensitivity for
memoryalone (case sensitivity of other units is maintained), especially when the case ofmemoryhas its meaning:pymatgen/pymatgen/core/units.py
Lines 90 to 91 in 14b7357
Fix
FloatWithUnit.from_strto correctly detectunit_typefrom string with space between value and unitPreviously for a string with space (which adheres to the SI Unit rules) like
Memory.from_str("1 MB"), the string would be split into1andMB, and the space inMBprevents theunit_typebeing detected properly and ended up beingNone.