def test_evaluate_cartesian_no_verify(self): s_t_vals = (0.25, 1.0) nodes = np.asfortranarray([[1.0, 2.0, 1.0], [1.0, 1.5, 2.75]]) triangle = self._make_one(nodes, 1) expected = np.asfortranarray([[1.25], [2.875]]) result = triangle.evaluate_cartesian(*s_t_vals, _verify=False) self.assertEqual(result, expected)
def test_evaluate_cartesian(self): s_t_vals = (0.125, 0.125) nodes = np.asfortranarray([[1.0, 2.0, 1.0], [1.0, 1.5, 2.75]]) triangle = self._make_one(nodes, 1) expected = np.asfortranarray([[1.125], [1.28125]]) result = triangle.evaluate_cartesian(*s_t_vals) self.assertEqual(result, expected)
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_evaluate_cartesian_calls_helper(self): nodes = self.ZEROS triangle = self._make_one_no_slots(nodes, 1, copy=False) patch = unittest.mock.patch( "bezier._triangle_helpers.evaluate_barycentric", return_value=unittest.mock.sentinel.point, ) s_val = 0.25 t_val = 0.25 with patch as mocked: result = triangle.evaluate_cartesian(s_val, t_val) self.assertIs(result, unittest.mock.sentinel.point) mocked.assert_called_once_with(nodes, 1, 0.5, s_val, t_val)
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)