Exemple #1
0
 def test_zero_atoms(self, universe):
     """Test error if zero atoms are present after conversion."""
     analysis_parameters = {"atomgroup": "name foo"}
     with pytest.raises(ValueError, match="AtomGroup `-atomgroup` with "):
         convert_analysis_parameters(
             analysis_callable=RMSF,
             analysis_parameters=analysis_parameters,
             reference_universe=universe)
Exemple #2
0
    def test_multi_atomgroup_fail(self, universe):
        """Test error raise for empty atomgroup for multiple AtomGroups."""
        analysis_parameters = {"p0": ["name foo"]}

        with pytest.raises(ValueError, match="AtomGroup `-p0` with "):
            convert_analysis_parameters(
                analysis_callable=complete_docstring,
                analysis_parameters=analysis_parameters,
                reference_universe=universe)
Exemple #3
0
    def test_multi_atomgroup(self, universe):
        """Test conversion of a list containing multiple AtomGroups."""
        selection_keywords = ["name OW", "name HW*"]
        analysis_parameters = {"p0": ["name OW", "name HW*"]}

        convert_analysis_parameters(analysis_callable=complete_docstring,
                                    analysis_parameters=analysis_parameters,
                                    reference_universe=universe)

        for i, sel in enumerate(selection_keywords):
            assert universe.select_atoms(sel) == analysis_parameters["p0"][i]
Exemple #4
0
    def test_None(self, universe):
        """Test that `None` objects are NOT converted.

        Could be default arguments
        """
        analysis_parameters = {"atomgroup": None}
        convert_analysis_parameters(analysis_callable=RMSF,
                                    analysis_parameters=analysis_parameters,
                                    reference_universe=universe)

        assert analysis_parameters["atomgroup"] is None
Exemple #5
0
    def test_multi_atomgroup_None(self, universe):
        """Test that `None` objects are NOT converted.

        Could be default arguments
        """
        analysis_parameters = {"p0": None}

        convert_analysis_parameters(analysis_callable=complete_docstring,
                                    analysis_parameters=analysis_parameters,
                                    reference_universe=universe)

        assert analysis_parameters["p0"] is None
Exemple #6
0
    def test_only_set_if_key_exists(self, universe):
        """
        Test if keys exist.

        The docparser does not distinguis between mandatory and positional
        arguments. So we only should set the value if it is inside the dict.
        """
        analysis_parameters = {}
        convert_analysis_parameters(analysis_callable=RMSF,
                                    analysis_parameters=analysis_parameters,
                                    reference_universe=universe)
        assert not analysis_parameters
Exemple #7
0
    def test_Atomgroup(self, universe):
        """Test AtomGroup conversion."""
        analysis_parameters = {"atomgroup": "all"}
        test_Universe = convert_analysis_parameters(
            analysis_callable=RMSF,
            analysis_parameters=analysis_parameters,
            reference_universe=universe)

        # `None` is returned if no Universe is created
        assert test_Universe is None
        assert analysis_parameters["atomgroup"] == universe.atoms
Exemple #8
0
    def test_Universe_creation(self, universe):
        """Test the universe creation from different parameters."""
        analysis_parameters = {}
        analysis_parameters["topology_u"] = TPR
        analysis_parameters["topology_format_u"] = None
        analysis_parameters["coordinates_u"] = XTC
        analysis_parameters["trajectory_format_u"] = None
        analysis_parameters["atom_style_u"] = None
        analysis_parameters["dimensions_u"] = None

        test_u = convert_analysis_parameters(
            analysis_callable=EinsteinMSD,
            analysis_parameters=analysis_parameters,
            reference_universe=None)

        # Extra parameters should be removed
        assert len(analysis_parameters.keys()) == 1
        assert analysis_parameters["u"] is test_u

        # We can not test accros several universes so we just compare
        # the atomic positions
        assert (universe.atoms.positions == test_u.atoms.positions).all()