def test_locate_bad_point(self): triangle = self._make_one(self.QUADRATIC, 2) point1 = np.asfortranarray([0.0, 1.0]) point2 = np.asfortranarray([[0.0, 1.0, 2.0]]) with self.assertRaises(ValueError): triangle.locate(point1) with self.assertRaises(ValueError): triangle.locate(point2)
def test_locate_no_verify(self): triangle = self._make_one(self.QUADRATIC, 2) s = 0.125 t = 0.125 x_val, y_val = triangle.evaluate_cartesian(s, t).flatten() point = np.asfortranarray([[x_val, np.nan], [y_val, np.nan]]) # Make sure it fails. with self.assertRaises(ValueError): triangle.locate(point) # Will only use the first row if _verify=False. computed_s, computed_t = triangle.locate(point, _verify=False) self.assertEqual(s, computed_s) self.assertEqual(t, computed_t)
def test_locate_bad_dimension(self): nodes = np.asfortranarray([[0.0, 1.0, 2.0]]) triangle = self._make_one(nodes, 1) with self.assertRaises(NotImplementedError): triangle.locate(None)
def test_locate(self): triangle = self._make_one(self.QUADRATIC, 2) point = triangle.evaluate_cartesian(0.5, 0.25) s, t = triangle.locate(point) self.assertEqual(s, 0.5) self.assertEqual(t, 0.25)