curve.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:CElegansBehaviour 作者: ChristophKirst 项目源码 文件源码
def get_values(self, points = None, parameter = None, dimension = None, derivative = 0, extrapolation = 1):
    """Calculates the values of the curve along the sample points

    Arguments:
      points (array or None): the sample points for the values, if None use internal samples points
      parameter (array or None): the bspline parameter, if None use internal parameter
      dimensions (None, list or int): the dimension(s) for which to return values
      derivative (int): the order of the derivative
      extrapolation (int):  0=extrapolated value, 1=return 0, 2=raise a ValueError, 3=boundary value

    Returns:
      array: the values of the spline at the sample points
    """

    if dimension is None:
      dimension = range(self.ndim);
    if isinstance(dimension,int):
      dimension = [dimension];   

    points = self.get_points(points, error = 'sample points need to be specified for the calculation of the values of this curve!')   

    if parameter is None:
      parameter = self._parameter[:,dimension];

    if points is self._points and derivative == 0:
      if parameter is self._parameter and self._values is not None: #cached version
        return self._values[:,dimension];
      if self.with_projection:
        return self.projection.dot(parameter);

    # full interpolation
    tck = (self._knots_all, parameter.T, self.degree);
    values = splev(points, tck, der = derivative, ext = extrapolation);  
    return np.vstack(values).T
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号