Skip to content

LinearDensity should have more reliable tests #3603

Open
@BFedder

Description

@BFedder

Is your feature request related to a problem?

Currently, some of the tests in test_lineardensity.py are basically tautologies because the expected values the tests check against were obtained by running lineardensity.py. This is the case for the following expected values:

expected_xchar_atoms
expected_xpos_residues
expected_xchar_residues
expected_xpos_segments
expected_xchar_segments
expected_xpos_fragments
expected_xchar_fragments

The current test Universe u = mda.Universe(waterPSF, waterDCD) is not ideal for determining charge densities by residues, segments, or fragments, because in these groupings the overall charge is zero.

Describe the solution you'd like

The expected values should be obtained independently from LinearDensity so that the tests are actually meaningful.

@PicoCentauri had the following suggestion for how this might be achieved:

Generate a trajectory based on random positions of particles in a cubic box. Draw the positions from a uniform distribution. Run the analysis and compare the densities. You could do three kinds of system: uncharged particles, charged particles and maybe charged dimers.

Describe alternatives you've considered

Currently, expected_xpos_atoms came from a different source. One could look into how these values were originally determined and replicate this for the other test cases.

Additional context

This came up in a discussion on PR #3572

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions