-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LinearDensity now working with residues/segments (#3572)
Fixes #3571 : LinearDensity does not work on residues or segments MDAnalysis/analysis/lineardensity.py: - in _prepare(self): - try/except statement replaced by if statements checking the grouping specified for LinearDensity. - masses and charges are obtained in a way appropriate for each case. - Floating point arithmetic issues could lead to negative radicands. A check was implemented to set numbers which are close to zero to precisely zero before the square root (for standard deviation) is calculated. - renamed previous test function and added expected masses and charges - added test functions for the other groupings with their respective expected masses and charges Changed the if/if/if for reading masses and charges to if/elif/else. Will now raise an AttributeError if invalid grouping is chosen. 'residues', 'segments' and 'fragments' now use the same logic (elem.atoms.total_mass()). * Changed test of radicand to only convert negative numbers to 0 * Now uses CoM rather than CoG for density calculations * Changed Class docstring to reflect change to CoM * Now uses parameter for compound instead of list comprehension when calculating masses, charges, and CoM * refactored test_lineardensity.py, make use of pytest functionality better * Added test for case of invalid grouping selection Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
111 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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