copapy.interp#

copapy.interp(x, xp, fp, method='linear')#

One-dimensional interpolation of a table.

Overloads:
  • x (float | int), xp (ArrayType[Any] | array[Any] | Sequence[float | value[Any]]), fp (ArrayType[Any] | array[Any] | Sequence[float | value[Any]]), method (str) = 'linear' → value[float] | float

  • x (value[Any]), xp (ArrayType[Any] | array[Any] | Sequence[float | value[Any]]), fp (ArrayType[Any] | array[Any] | Sequence[float | value[Any]]), method (str) = 'linear' → value[float]

  • x (vector[Any]), xp (ArrayType[Any] | array[Any] | Sequence[float | value[Any]]), fp (ArrayType[Any] | array[Any] | Sequence[float | value[Any]]), method (str) = 'linear' → vector[float]

  • x (tensor[Any]), xp (ArrayType[Any] | array[Any] | Sequence[float | value[Any]]), fp (ArrayType[Any] | array[Any] | Sequence[float | value[Any]]), method (str) = 'linear' → tensor[float]

  • x (array[Any]), xp (ArrayType[Any] | array[Any] | Sequence[float | value[Any]]), fp (ArrayType[Any] | array[Any] | Sequence[float | value[Any]]), method (str) = 'linear' → array[float]

Outside of the range of xp the first or last value of fp is returned. The position in the table is computed by two scalar operations if xp is a uniform grid of numbers, otherwise by a binary search. For the method ‘linear’ x = nan results in nan.

Parameters:
  • x (Any) – Position(s) to evaluate

  • xp (ArrayType[Any] | array[Any] | Sequence[float | value[Any]]) – Increasing points of the table: a sequence of numbers or copapy values, a vector, 1D tensor or 1D array with at least two elements

  • fp (ArrayType[Any] | array[Any] | Sequence[float | value[Any]]) – Values of the table at the points xp, with the same number of elements as xp.

  • method (str) – ‘linear’ for the linear interpolation between two points, ‘previous’ for the value of the last point not larger than x or ‘nearest’ for the value of the point closest to x

Returns:

Interpolated value(s) with the shape of x.