Fix InterRDF_s when given density=True#2812
Fix InterRDF_s when given density=True#2812orbeckst merged 2 commits intoMDAnalysis:developfrom VOD555:fix_rdf_density
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2812 +/- ##
===========================================
- Coverage 92.22% 92.21% -0.01%
===========================================
Files 184 184
Lines 24141 24138 -3
Branches 3123 3123
===========================================
- Hits 22263 22260 -3
Misses 1813 1813
Partials 65 65
Continue to review full report at Codecov.
|
orbeckst
left a comment
There was a problem hiding this comment.
Please add an entry to CHANGELOG.
Could you add note in the docs for InterRDF_s what the normalization is, namely, the mathematical equation for the site RDF?
|
Btw, there's an error in the reST for Could you please fix it while you're at it? Thanks. |
|
Hello @VOD555! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2020-07-10 23:50:35 UTC |
|
Add a section or paragraph at the top where you explain InterRDF_s with the equation.
… Am 08.07.2020 um 11:05 schrieb Shujie Fan ***@***.***>:
@VOD555 commented on this pull request.
In package/MDAnalysis/analysis/rdf.py:
> indices.append([ag1.indices, ag2.indices])
# Average number density
box_vol = self.volume / self.n_frames
- density = N / box_vol
Where should I put the equation, at the top below the g_ab(r) or in the texts for InterRDF_s?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
orbeckst
left a comment
There was a problem hiding this comment.
There's only a horizontal rule that needs to stay in CHANGELOG.
While you're at it, can you please fix/update some of the reST? Thanks.
- for MDAnalysis.analysis.rdf.InterRDF_s.get_cdf and make sure that the math and Returns display properly (needs a
r"""at the beginning and perhaps a blank line). - add a section
Attributesto InterRDF and InterRDF_s and list the attributes in which results are storedbins, rdf, edges, countandbins, rdf, edges, count, indices, cdf(I think). See our doc guidelines or examples how to add Attributes.
The other comments can be addressed after this PR is merged.
| In :class:`InterRDF_s`, we provide an option `density`. When `density` is | ||
| `True`, it will return the RDF :math:`g_{ab}(r)`; when `density` is False`, | ||
| it will return the density of particle :math:`b` in a shell at distance | ||
| :math:`r` around a :math:`a` particle, which is | ||
|
|
||
| .. math:: | ||
| n_{ab}(r) = \rho g_{ab}(r) |
There was a problem hiding this comment.
This is confusing: if we set density=False then we get a density?!?
We should then change the kwarg setting to density=True to get the density.
I want to add the fix to the backport PR #2798 so we cannot change the defaults as this can break people's code.
We can make a second PR to change this.
package/MDAnalysis/analysis/rdf.py
Outdated
| Calculate :math:`g_{ab}(r)` if set to ``True``; or calculate | ||
| :math:`n_{ab}(r)` if set to ``false``; the default is | ||
| ``True``. |
There was a problem hiding this comment.
Reverse so that density=True calculates the number density n_ab(r).
I want to add the fix to the backport PR #2798 so we cannot change the defaults as this can break people's code.
We can make a second PR to change this.
|
To be used for squashed commit message |
|
@VOD555, I'll quickly add the doc fix ups while I am merging... |
| * rdf.InterRDF_s density keyword documented and now gives correct results for | ||
| density=True; the keyword was available since 0.19.0 but with incorrect | ||
| semantics and not documented and did not produce correct results (Issue | ||
| #2811, PR #2812) |
There was a problem hiding this comment.
I changed the meaning of the density keyword so that it makes more sense. Given that we never documented it, this should be ok and I will classify it as a fix so that it can go into 1.0.1 PR #2798
| In :class:`InterRDF_s`, we provide an option `density`. When `density` is | ||
| ``False``, it will return the RDF :math:`g_{ab}(r)`; when `density` is | ||
| ``True``, it will return the density of particle :math:`b` in a shell at | ||
| distance :math:`r` around a :math:`a` particle, which is |
There was a problem hiding this comment.
Note that density=False now means "calculate g(r)" and density=True means "calculate density".
There was a problem hiding this comment.
So we still need another PR to change the default density, right?
There was a problem hiding this comment.
No, this PR switched the behavior.
| This is the :ref:`cumulative count<equation-countab>` within a given | ||
| radius, i.e., :math:`N_{ab}(r)`. |
There was a problem hiding this comment.
Why are we calculating the counts and calling it CDF? This is confusing...
I made it clear in the text but still: why did we do this instead of having separate methods that just do the thing that they are named after?
There was a problem hiding this comment.
Yes, we should have seperate functions to give CDF and cummulative N.
There was a problem hiding this comment.
@VOD555 can you raise issues for MDAnalysis and PMDA, please?
- fix #2811 (see also MDAnalysis/pmda#120) - add test to compare InterRDF and InterRDF_s - add description for density option (was not documented since 0.19.0) - updated docs for rdf - updated docs with equationi - attributes for InterRDF and InterRDF_s - reference equations - minor grammar/style fixes - remove ill-advised usage of InterRDF_s from docs - update CHANGELOG
- fix (because it was not documented before) - density=True now means "calculate the single site density"; default is still "calculate RDF" (now meaning density=False) - update docs - update tests (add test for default behavior) - update CHANGELOG
|
I rewrote the history so that it can be nicely merged. |
Fixes #2811
Changes made in this Pull Request:
PR Checklist