| | import pytest |
| | import numpy as np |
| | from time import time |
| | from polire import ( |
| | IDW, |
| | Spline, |
| | Trend, |
| | |
| | Kriging, |
| | NaturalNeighbor, |
| | SpatialAverage, |
| | CustomInterpolator, |
| | |
| | ) |
| | 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(), |
| | |
| | Kriging(), |
| | NaturalNeighbor(), |
| | SpatialAverage(), |
| | CustomInterpolator(LinearRegression()), |
| | |
| | ], |
| | ) |
| | 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() |
| | print("Passed", "Time:", np.round(time() - init, 3), "seconds") |
| |
|