Fix MolecularFormula._calc_kmd ignoring kendrick_rounding_method#29
Open
robertyoung3 wants to merge 1 commit intoEMSL-Computing:masterfrom
Open
Fix MolecularFormula._calc_kmd ignoring kendrick_rounding_method#29robertyoung3 wants to merge 1 commit intoEMSL-Computing:masterfrom
robertyoung3 wants to merge 1 commit intoEMSL-Computing:masterfrom
Conversation
227e2f8 to
ff63e11
Compare
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
MolecularFormulaCalc._calc_kmd()usesint()to derive the nominal Kendrick mass, which always truncates toward zero (equivalent tofloorfor positive values)kendrick_rounding_methodsetting (floor/ceil/round) thatMSPeakCalc._calc_kmd()already respectskendrick_rounding_methodfrom the parent peak's settings (orMSParameters.ms_peakas fallback) and applies the samefloor/ceil/rintlogicBefore
After
Context
MSPeakCalc._calc_kmd()(for experimental m/z) already respects this setting.MolecularFormulaCalc._calc_kmd()(for theoretical m/z) was inconsistent. With the defaultkendrick_rounding_method="floor", the behavior is unchanged sinceint()andfloor()are equivalent for positive values.Test plan
floor) is unchanged —int()andfloor()produce identical results for positive Kendrick masseskendrick_base(parent peak settings → MSParameters fallback)hasattrguard for safety when_mspeak_parentis not yet set