interpol/test.py

18 lines
484 B
Python

# coding: utf-8
from interpol.spline.linear.do import Interpolator
import numpy as np
import matplotlib.pyplot as plt
X = np.arange(0, 30, 0.3)
Y = np.cos(X)
i = Interpolator(X, Y)
X_bar = np.arange(0, 30, 0.01)
Y_bar = np.cos(X_bar)
interpolated = np.array([i.eval_float((f,)) for f in X_bar])
results_half = i.equals_float((0.5,))
y_half = [0.5 for x in results_half]
plt.plot(X_bar, interpolated, "r-")
plt.plot(X_bar, Y_bar, "g-")
plt.plot(results_half, y_half, "bo")
plt.show()