Exemplo n.º 1
0
 def test_wrong_symbol(self):
     wrong_data = {
         "atom_0": {
             "sort": self._good_data["atom_0"]["sort"],
             "symbol": "CA",  # valid is Ca not CA
             "coord": self._good_data["atom_0"]["coord"],
             "mass": self._good_data["atom_0"]["mass"]
         }
     }
     with self.assertRaises(ValueError):
         AtomsData._check_item(wrong_data)
Exemplo n.º 2
0
    def test_wrong_mass(self):
        wrong_data = {
            "atom_0": {
                "sort": self._good_data["atom_0"]["sort"],
                "symbol": self._good_data["atom_0"]["symbol"],
                "coord": self._good_data["atom_0"]["coord"],
                "mass": -1.0
            }
        }
        with self.assertRaises(ValueError):
            AtomsData._check_item(wrong_data)

        wrong_data["mass"] = 28  # int instead of float
        with self.assertRaises(ValueError):
            AtomsData._check_item(wrong_data)
Exemplo n.º 3
0
    def test_wrong_sort(self):
        # too large
        wrong_data = {
            "atom_0": {
                "sort": 2,
                "symbol": self._good_data["atom_0"]["symbol"],
                "coord": self._good_data["atom_0"]["coord"],
                "mass": self._good_data["atom_0"]["mass"]
            }
        }

        with self.assertRaises(ValueError):
            AtomsData._check_item(wrong_data["atom_0"], n_atoms=1)

        # negative
        wrong_data["atom_0"]["sort"] = -1,

        with self.assertRaises(ValueError):
            AtomsData._check_item(wrong_data["atom_0"])

        # string instead of number
        wrong_data["atom_0"]["sort"] = "-1"

        with self.assertRaises(ValueError):
            AtomsData._check_item(wrong_data["atom_0"])
Exemplo n.º 4
0
    def test_wrong_coord(self):
        wrong_data = {
            "atom_0": {
                "sort": self._good_data["atom_0"]["sort"],
                "symbol": self._good_data["atom_0"]["symbol"],
                "coord": "wrong",
                "mass": self._good_data["atom_0"]["mass"]
            }
        }
        with self.assertRaises(ValueError):
            AtomsData._check_item(wrong_data)

        wrong_data["coord"] = np.asarray([[1, 2], [4]])
        with self.assertRaises(ValueError):
            AtomsData._check_item(wrong_data)

        wrong_data["coord"] = np.asarray([1, 2])
        with self.assertRaises(ValueError):
            AtomsData._check_item(wrong_data)
Exemplo n.º 5
0
    def test_wrong_atom(self):
        wrong_data = {
            "atom_0": {
                "sort": self._good_data["atom_0"]["sort"],
                "symbol": self._good_data["atom_0"]["symbol"],
                "coord": self._good_data["atom_0"]["coord"],
                "mass": self._good_data["atom_0"]["mass"]
            }
        }

        with self.assertRaises(ValueError):
            AtomsData._check_item(wrong_data)

        wrong_data["atom"] = 2
        with self.assertRaises(ValueError):
            AtomsData._check_item(wrong_data)

        wrong_data["atom"] = 3
        with self.assertRaises(ValueError):
            AtomsData._check_item(wrong_data)