# Path: skyfield/curvelib.py
# class Splines(object):
#     def __init__(self, table):
#         table = _to_array(table)
#         if len(table.shape) < 2:  # Let caller provide a single row.
#             table = table.reshape(table.shape + (1,))
#         self.table = table
#         self.lower = lower = table[0]
#         self.upper = upper = table[1]
#         self._width = upper - lower
#         self._n = arange(len(lower))
#         self.coefficients = table[2:]
# 
#     def __call__(self, x):
#         i = interp(x, self.lower, self._n)
#         i = i.astype(int)
#         t = (x - self.lower[i]) / self._width[i]
#         coefficients = iter(self.coefficients)
#         value = next(coefficients)[i]
#         for c in coefficients:
#             value *= t
#             value += c[i]
#         return value
# 
#     @reify
#     def derivative(self):
#         columns = [self.table[0], self.table[1]]
#         coefficients = self.table[2:-1]
#         for i, c in enumerate(coefficients):
#             n = len(coefficients) - i
#             columns.append(n * c / self._width)
#         return Splines(columns)
# 
# def build_spline_given_ends(x0, y0, slope0, x1, y1, slope1):
#     width = x1 - x0
#     slope0 = slope0 * width
#     slope1 = slope1 * width
#     a0 = y0
#     a1 = slope0
#     a2 = -2*slope0 - slope1 - 3*y0 + 3*y1
#     a3 = slope0 + slope1 + 2*y0 - 2*y1
#     return x0, x1, a3, a2, a1, a0


from skyfield.curvelib import Splines, build_spline_given_ends

def test_spline_and_derivative():
    parameters = 10, 12, 2.0, 3.0, 5.0, 7.0
    x = 8.0, 9.0, 10.0, 11.0, 12.0
    expected_values = 3.0, 5.0, 7.0, 10.5, 17.0
    expected_slope = 2.5, 1.75, 2.5, 4.75, 8.5

    # Does the Spline class work?


# Path: skyfield/curvelib.py
# class Splines(object):
#     def __init__(self, table):
#         table = _to_array(table)
#         if len(table.shape) < 2:  # Let caller provide a single row.
#             table = table.reshape(table.shape + (1,))
#         self.table = table
#         self.lower = lower = table[0]
#         self.upper = upper = table[1]
#         self._width = upper - lower
#         self._n = arange(len(lower))
#         self.coefficients = table[2:]
# 
#     def __call__(self, x):
#         i = interp(x, self.lower, self._n)
#         i = i.astype(int)
#         t = (x - self.lower[i]) / self._width[i]
#         coefficients = iter(self.coefficients)
#         value = next(coefficients)[i]
#         for c in coefficients:
#             value *= t
#             value += c[i]
#         return value
# 
#     @reify
#     def derivative(self):
#         columns = [self.table[0], self.table[1]]
#         coefficients = self.table[2:-1]
#         for i, c in enumerate(coefficients):
#             n = len(coefficients) - i
#             columns.append(n * c / self._width)
#         return Splines(columns)
# 
# def build_spline_given_ends(x0, y0, slope0, x1, y1, slope1):
#     width = x1 - x0
#     slope0 = slope0 * width
#     slope1 = slope1 * width
#     a0 = y0
#     a1 = slope0
#     a2 = -2*slope0 - slope1 - 3*y0 + 3*y1
#     a3 = slope0 + slope1 + 2*y0 - 2*y1
#     return x0, x1, a3, a2, a1, a0


# Path: skyfield/tests/test_curves.py
from skyfield.curvelib import Splines, build_spline_given_ends


def test_spline_and_derivative():
    parameters = 10, 12, 2.0, 3.0, 5.0, 7.0
    x = 8.0, 9.0, 10.0, 11.0, 12.0
    expected_values = 3.0, 5.0, 7.0, 10.5, 17.0
    expected_slope = 2.5, 1.75, 2.5, 4.75, 8.5

    # Does the Spline class work?


    curve = Splines(parameters)