-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathtest_clough_tocher.py
More file actions
41 lines (32 loc) · 993 Bytes
/
test_clough_tocher.py
File metadata and controls
41 lines (32 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import numpy as np
import pytest
from ezyrb import CloughTocher
np.random.seed(17)
def get_xy():
npts = 20
dinput = 2
inp = np.random.uniform(-1, 1, size=(npts, dinput))
out = np.array([
np.sin(inp[:, 0]) + np.sin(inp[:, 1]**2),
np.cos(inp[:, 0]) + np.cos(inp[:, 1]**2)
]).T
return inp, out
class TestCloughTocher:
def test_constructor_empty(self):
model = CloughTocher()
def test_fit(self):
x, y = get_xy()
approx = CloughTocher()
approx.fit(x, y)
def test_predict_01(self):
x, y = get_xy()
approx = CloughTocher()
approx.fit(x, y)
test_y = approx.predict(x)
np.testing.assert_array_almost_equal(y, test_y, decimal=6)
def test_wrong_dimensions(self):
x = np.random.uniform(-1, 1, size=(10, 3))
y = np.random.uniform(-1, 1, size=(10, 2))
approx = CloughTocher()
with pytest.raises(ValueError):
approx.fit(x, y)