def setUp(self): self.surrogate = NNeighborSurrogate(interpolant_type='linear') self.x = np.array([[0., 0.], [2., 0.], [2., 2.], [0., 2.], [1., 1.]]) self.y = np.array([[1., 0., .5, 1.], [1., 0., .5, 1.], [1., 0., .5, 1.], [1., 0., .5, 1.], [0., 1., .5, 0.]]) self.surrogate.fit(self.x, self.y)
def test_unrecognized_type(self): with self.assertRaises(ValueError) as cm: NNeighborSurrogate(interpolant_type='junk') expected_msg = "NNeighborSurrogate: interpolant_type 'junk' not supported." \ " interpolant_type must be one of ['linear', 'weighted'," \ " 'rbf']." self.assertEqual(expected_msg, str(cm.exception))
def setUp(self): self.surrogate = NNeighborSurrogate(interpolant_type='rbf', n=4) self.x = np.array([[0.], [1.], [2.], [3.]]) self.y = np.array([[0.], [2.], [2.], [0.]]) self.surrogate.fit(self.x, self.y)