Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The rules for this file:
* 2.9.0

Fixes
* Fixes invalid default unit from Angstrom to Angstrom^{-3} for convert_density() function. (Issue #4829)
* Fixes deprecation warning Array to scalar convertion. Replaced atan2() with np.arctan2() (Issue #4339)
* Replaced mutable defaults with None and initialized them within
the function to prevent shared state. (Issue #4655)
Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/analysis/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ def convert_length(self, unit='Angstrom'):
self.units['length'] = unit
self._update() # needed to recalculate midpoints and origin

def convert_density(self, unit='Angstrom'):
def convert_density(self, unit='Angstrom^{-3}'):
"""Convert the density to the physical units given by `unit`.

Parameters
Expand Down
6 changes: 6 additions & 0 deletions testsuite/MDAnalysisTests/analysis/test_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,12 @@ def test_warn_results_deprecated(self, universe):
with pytest.warns(DeprecationWarning, match=wmsg):
assert_equal(D.density.grid, D.results.density.grid)

def test_density_analysis_conversion_default_unit(self):
u = mda.Universe(TPR, XTC)
ow = u.select_atoms("name OW")
D = mda.analysis.density.DensityAnalysis(ow, delta=1.0)
D.run()
D.results.density.convert_density()

class TestGridImport(object):

Expand Down