File size: 1,129 Bytes
9af7384 |
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import pytest
import numpy as np
from time import time
from polire import (
IDW,
Spline,
Trend,
# GP,
Kriging,
NaturalNeighbor,
SpatialAverage,
CustomInterpolator,
# NSGP,
)
from sklearn.linear_model import LinearRegression
X = np.random.rand(20, 2)
y = np.random.rand(20)
X_new = np.random.rand(40, 2)
@pytest.mark.parametrize(
"model",
[
IDW(),
Spline(),
Trend(),
# GP(),
Kriging(),
NaturalNeighbor(),
SpatialAverage(),
CustomInterpolator(LinearRegression()),
# NSGP(),
],
)
def test_fit_predict(model):
init = time()
model.fit(X, y)
y_new = model.predict(X_new)
assert y_new.shape == (40,)
print("Passed", "Time:", np.round(time() - init, 3), "seconds")
@pytest.mark.skip(reason="Temporarily disabled")
def test_nsgp():
model = NSGP()
init = time()
model.fit(X, y, **{"ECM": X @ X.T})
y_new = model.predict(X_new)
assert y_new.shape == (40,)
assert y_new.sum() == y_new.sum() # No NaN
print("Passed", "Time:", np.round(time() - init, 3), "seconds")
|