Example #1
0
 def test6(self):
     """test getEnergyGradient returns grad of wrong size"""
     p1 = _ReturnBad1()
     p1.getEnergyGradient = lambda x: (1., np.zeros(x.size - 1))
     p = _TestingCppPotentialWrapper(p1)
     with self.assertRaises(IndexError):
         e = p.cpp_get_energy_gradient(_xrand)
Example #2
0
 def test4(self):
     """test getEnergyGradient returns invalid grad"""
     p1 = _ReturnBad1()
     p1.getEnergyGradient = lambda x: (1., (1., "not numpy array"))
     p = _TestingCppPotentialWrapper(p1)
     with self.assertRaises(ValueError):
         e = p.cpp_get_energy_gradient(_xrand)
Example #3
0
 def test5(self):
     """test getEnergyGradient returns list for grad"""
     p1 = _ReturnBad1()
     p1.getEnergyGradient = lambda x: (1., list(np.zeros(x.size)))
     p = _TestingCppPotentialWrapper(p1)
     # this should not raise anything
     e = p.cpp_get_energy_gradient(_xrand)
Example #4
0
 def test2(self):
     """test getEnergyGradient returns not tuple"""
     p1 = _ReturnBad1()
     p1.getEnergyGradient = lambda s, x: None
     p = _TestingCppPotentialWrapper(p1)
     with self.assertRaises(TypeError):
         e = p.cpp_get_energy_gradient(_xrand)
Example #5
0
 def test3(self):
     """test getEnergyGradient returns invalid energy"""
     p1 = _ReturnBad1()
     p1.getEnergyGradient = lambda x: ("not energy", np.zeros(x.size))
     p = _TestingCppPotentialWrapper(p1)
     with self.assertRaises(TypeError):
         e = p.cpp_get_energy_gradient(_xrand)
 def test6(self):
     """test getEnergyGradient returns grad of wrong size"""
     p1 = _ReturnBad1()
     p1.getEnergyGradient = lambda x: (1., np.zeros(x.size - 1))
     p = _TestingCppPotentialWrapper(p1)
     with self.assertRaises(IndexError):
         e = p.cpp_get_energy_gradient(_xrand)
 def test5(self):
     """test getEnergyGradient returns list for grad"""
     p1 = _ReturnBad1()
     p1.getEnergyGradient = lambda x: (1., list(np.zeros(x.size)))
     p = _TestingCppPotentialWrapper(p1)
     # this should not raise anything
     e = p.cpp_get_energy_gradient(_xrand)
 def test4(self):
     """test getEnergyGradient returns invalid grad"""
     p1 = _ReturnBad1()
     p1.getEnergyGradient = lambda x: (1., (1., "not numpy array"))
     p = _TestingCppPotentialWrapper(p1)
     with self.assertRaises(ValueError):
         e = p.cpp_get_energy_gradient(_xrand)
 def test3(self):
     """test getEnergyGradient returns invalid energy"""
     p1 = _ReturnBad1()
     p1.getEnergyGradient = lambda x: ("not energy", np.zeros(x.size))
     p = _TestingCppPotentialWrapper(p1)
     with self.assertRaises(TypeError):
         e = p.cpp_get_energy_gradient(_xrand)
 def test2(self):
     """test getEnergyGradient returns not tuple"""
     p1 = _ReturnBad1()
     p1.getEnergyGradient = lambda s, x: None
     p = _TestingCppPotentialWrapper(p1)
     with self.assertRaises(TypeError):
         e = p.cpp_get_energy_gradient(_xrand)
Example #11
0
 def test1(self):
     """test getEnergy returns not double"""
     p = _TestingCppPotentialWrapper(_ReturnBad1())
     with self.assertRaises(TypeError):
         e = p.cpp_get_energy(_xrand)
 def test1(self):
     """test getEnergy returns not double"""
     p = _TestingCppPotentialWrapper(_ReturnBad1())
     with self.assertRaises(TypeError):
         e = p.cpp_get_energy(_xrand)