Exemple #1
0
 def __init__(self, x, y):
     if len(x) != len(y):
         raise ValueError("x and y must have the same length.")
     if ((x[1:] - x[:-1]) < 0).any():
         raise ValueError("x must be a sorted array.")
     self.x = numpy.array(x, float, copy=False)
     self.y = numpy.array(y, float, copy=False)
     self.d = numpy.zeros(len(self.x), float)
     spline_construct(self.x,self.y,self.d)
Exemple #2
0
def test_blind2():
    # see whether we get segfaults or not.
    x = numpy.arange(0, 1.005, 0.1) * numpy.pi * 2
    y = numpy.sin(x)
    d = numpy.zeros(len(x), float)
    spline_construct(x, y, d)
    x_new = numpy.arange(0, 1.0005, 0.01) * numpy.pi * 2
    y_new = numpy.zeros(len(x_new), float)
    spline_eval(x, y, d, x_new, y_new)
    yint_spline = numpy.zeros(len(y), float)
    spline_cumul_int(x, y, d, yint_spline)
Exemple #3
0
def test_blind1():
    # see whether we get segfaults or not.
    x = numpy.arange(0, 1, 0.1)
    y = numpy.random.normal(0, 1, len(x))
    d = numpy.zeros(len(x), float)
    spline_construct(x, y, d)
    x_new = numpy.random.uniform(-1, 2, 50)
    y_new = numpy.zeros(len(x_new), float)
    spline_eval(x, y, d, x_new, y_new)
    yint = numpy.zeros(len(y), float)
    spline_cumul_int(x, y, d, yint)
Exemple #4
0
 def _get_weights_aux(self, us, vs):
     ys = numpy.zeros(len(us), float)
     ds = numpy.zeros(len(us), float)
     ws = numpy.zeros(len(us), float)
     for i in xrange(len(us)):
         ys[:] = 0
         if vs is None:
             ys[i] = 1
         else:
             ys[i] = vs[i]
         spline_construct(us, ys, ds)
         ws[i] = spline_int(us, ys, ds)
     return ws
Exemple #5
0
 def _get_weights_aux(self, us, vs):
     ys = numpy.zeros(len(us), float)
     ds = numpy.zeros(len(us), float)
     ws = numpy.zeros(len(us), float)
     for i in xrange(len(us)):
         ys[:] = 0
         if vs is None:
             ys[i] = 1
         else:
             ys[i] = vs[i]
         spline_construct(us,ys,ds)
         ws[i] = spline_int(us,ys,ds)
     return ws