Interpolate each var on the coordinates requested
439968
def interpolate(self, doy, depth, lat, lon, var):
        

        subset, dims = self.crop(doy, depth, lat, lon, var)

        if np.all([d in dims['time'] for d in doy]) & \
                np.all([z in dims['depth'] for z in depth]) & \
                np.all([y in dims['lat'] for y in lat]) & \
                np.all([x in dims['lon'] for x in lon]):
                    dn = np.nonzero([d in doy for d in dims['time']])[0]
                    zn = np.nonzero([z in depth for z in dims['depth']])[0]
                    yn = np.nonzero([y in lat for y in dims['lat']])[0]
                    xn = np.nonzero([x in lon for x in dims['lon']])[0]
                    output = {}
                    for v in subset:
                        # output[v] = subset[v][dn, zn, yn, xn]
                        # Seriously that this is the way to do it?!!??
                        output[v] = subset[v][:, :, :, xn][:, :, yn][:, zn][dn]
                    return output

        # The output coordinates shall be created only once.
        points_out = []
        for doyn in doy:
            for depthn in depth:
                for latn in lat:
                    for lonn in lon:
                        points_out.append([doyn, depthn, latn, lonn])
        points_out = np.array(points_out)

        output = {}
        for v in var:
            output[v] = ma.masked_all(
                    (doy.size, depth.size, lat.size, lon.size),
                    dtype=subset[v].dtype)

            # The valid data
            idx = np.nonzero(~ma.getmaskarray(subset[v]))

            if idx[0].size > 0:
                points = np.array([
                    dims['time'][idx[0]], dims['depth'][idx[1]],
                    dims['lat'][idx[2]], dims['lon'][idx[3]]]).T
                values = subset[v][idx]

                # Interpolate along the dimensions that have more than one
                #   position, otherwise it means that the output is exactly
                #   on that coordinate.
                ind = np.array(
                        [np.unique(points[:, i]).size > 1 for i in
                            range(points.shape[1])])
                assert ind.any()

                # These interpolators understand NaN, but not masks.
                values[ma.getmaskarray(values)] = np.nan

                values_out = griddata(
                        np.atleast_1d(np.squeeze(points[:, ind])),
                        values,
                        np.atleast_1d(np.squeeze(points_out[:, ind]))
                        )

                # Remap the interpolated value back into a 4D array
                idx = np.isfinite(values_out)
                for [t, z, y, x], out in zip(points_out[idx], values_out[idx]):
                    output[v][t==doy, z==depth, y==lat, x==lon] = out

            output[v] = ma.fix_invalid(output[v])

        return output
1115297
def interpolate(self):
        
        nans, x = utils.nan_idx(self)
        self[nans] = np.interp(x(nans), x(~nans), self[~nans])
        return self
148345
function interpolateRequest(params, bindings) {

  params.body = interpolate(params.body, bindings, { json: true })
  params.path = interpolate(params.path, bindings)
  for (var key in params.headers) {
    params.headers[key] = interpolate(params.headers[key], bindings)
  }
  return params
}
166535
def VariablesValues(self, variables, t):
        
        # TODO: put interpolation in variables
        if (t < self.te) | (t > 0):
            i = t//self.ts  # time step
            ti = self.ts*i
            if type(variables) == list:
                values = []
                for variable in variables:
                    # interpolation
                    values.append(
                        variables.values[i]*((ti-t)/self.ts+1)+variables.values[i+1]*(t-ti)/self.ts)
                return values

            else:
                # interpolation
                return variables.values[i]*((ti-t)/self.ts+1)+variables.values[i+1]*(t-ti)/self.ts
        else:
            raise ValueError
1052588
function getInterpolatedVariable() {
  const type = NodeType.InterpolatedVariableType;
  const token = tokens[pos];
  const line = token.ln;
  const column = token.col;
  const content = [];

  // Skip `@{`:
  pos += 2;

  content.push(getIdent());

  const end = getLastPosition(content, line, column, 1);

  // Skip `}`:
  pos++;

  return newNode(type, content, line, column, end);
}
977181
def format_variables(variables, join_lines=True):
  """"""
  rows = []
  rows.append(("Variable", "Shape", "Type", "Collections", "Device"))
  var_to_collections = _get_vars_to_collections(variables)
  for var in sorted(variables, key=lambda var: var.op.name):
    if var.get_shape().is_fully_defined():
      shape = "x".join(str(dim) for dim in var.get_shape().as_list())
    else:
      shape = "undefined"
    dtype = repr(var.dtype.base_dtype).replace("tf.", "")
    coll = ", ".join(sorted(var_to_collections[var]))
    rows.append((var.op.name, shape, dtype, coll, _format_device(var)))
  return _format_table(rows, join_lines)
785743
public String interpolate() {
        getValues();
        if (definition == null) {
            return "";
        }

        int variableStart = definition.indexOf("{");
        if (variableStart < 0) {
            return definition;
        }

        int index = 0;
        int variableEnd = 0;
        StringBuilder sb = new StringBuilder();
        while (variableStart >= 0) {
            sb.append(definition.substring(variableEnd,
                                           variableStart));
            variableEnd = getIndexForEndOfVariable(definition,
                                                   variableStart) + 1;
            variableStart = definition.indexOf("{",
                                               variableEnd);
            sb.append(values.get(index++).getValue());
        }
        if (variableEnd < definition.length()) {
            sb.append(definition.substring(variableEnd));
        }
        return sb.toString();
    }
230649
private void encodeIntern(final LNGVector<Literal> vars) {
    if (vars.size() <= this.groupSize)
      for (int i = 0; i + 1 < vars.size(); i++)
        for (int j = i + 1; j < vars.size(); j++)
          this.result.addClause(vars.get(i).negate(), vars.get(j).negate());
    else {
      final LNGVector<Literal> l1 = new LNGVector<>(vars.size() / 2);
      final LNGVector<Literal> l2 = new LNGVector<>(vars.size() / 2);
      int i = 0;
      for (; i < vars.size() / 2; i++)
        l1.push(vars.get(i));
      for (; i < vars.size(); i++)
        l2.push(vars.get(i));
      final Variable newVariable = this.result.newVariable();
      l1.push(newVariable);
      l2.push(newVariable.negate());
      this.encodeIntern(l1);
      this.encodeIntern(l2);
    }
  }
1300088
def _interpolate_line(xorig, yorig, xclick, yclick):
    """"""
    candidates = []
    # The closest point may be a vertex.
    for x, y in zip(xorig, yorig):
        candidates.append((np.hypot(xclick - x, yclick - y), (x, y)))
    # Or it may be a projection on a segment.
    for (x0, x1), (y0, y1) in zip(zip(xorig, xorig[1:]), zip(yorig, yorig[1:])):
        vec1 = np.array([x1 - x0, y1 - y0])
        vec1 /= np.linalg.norm(vec1)
        vec2 = np.array([xclick - x0, yclick - y0])
        dist_along = vec1.dot(vec2)
        x, y = np.array([x0, y0]) + dist_along * vec1
        # Drop if out of the segment.
        if (x - x0) * (x - x1) > 0 or (y - y0) * (y - y1) > 0:
            continue
        candidates.append((np.hypot(xclick - x, yclick - y), (x, y)))
    _, (x, y) = min(candidates)
    return x, y
817655
def log_interp(x, xp, *args, **kwargs):
    """"""
    return log_interpolate_1d(x, xp, *args, **kwargs)
457881
function interpolate(t) {
    var A = Math.sin(d - (t *= d)) / sd,
        B = Math.sin(t) / sd,
        x = A * cy0 * cx0 + B * cy1 * cx1,
        y = A * cy0 * sx0 + B * cy1 * sx1,
        z = A * sy0       + B * sy1;
    return [
      Math.atan2(y, x) / d3_geo_radians,
      Math.atan2(z, Math.sqrt(x * x + y * y)) / d3_geo_radians
    ];
  }
75233
function interpolatePairs( _ps, t1, t2 ) {
  var pn = [];
  for (var i=0; i<_ps.length; i++) {
    var next = (i==_ps.length-1) ? 0 : i+1;
    pn.push( new Pair( _ps[i].interpolate( t1 ) ).to( _ps[next].interpolate( 1-t2 ) ) );
  }
  return pn;
}
588520
function resample(coordinates) {
    var i = 0,
        n = coordinates.length,
        j,
        m,
        resampled = n ? [coordinates[0]] : coordinates,
        resamples,
        origin = arc.source();

    while (++i < n) {
      resamples = arc.source(coordinates[i - 1])(coordinates[i]).coordinates;
      for (j = 0, m = resamples.length; ++j < m;) resampled.push(resamples[j]);
    }

    arc.source(origin);
    return resampled;
  }
1301401
def _assign_values_to_unbound_vars(unbound_vars, unbound_var_values):
  """"""
  context = {}
  for key, value in six.iteritems(unbound_var_values):
    if key not in unbound_vars:
      raise ValueError('unexpected key: %s. Legal values are: %s' %
                       (key, list(six.iterkeys(unbound_vars))))
    context[unbound_vars[key]] = value
  unspecified = []
  for unbound_var in six.itervalues(unbound_vars):
    if unbound_var not in context:
      if unbound_var.has_default():
        context[unbound_var] = unbound_var.default
      else:
        unspecified.append(unbound_var.key)
  if unspecified:
    raise ValueError('Unspecified keys: %s' % unspecified)
  return context
505101
def interpolate_cubic(self, lons, lats, data):
        
        return self.interpolate(lons, lats, data, order=3)
1187963
function interpolate(string, object) {
    forOwn(object, function(value, key) {
      // escape regexp special characters in `key`
      string = string.replace(RegExp('#\\{' + key.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1') + '\\}', 'g'), value);
    });
    return string;
  }
551699
def interpolate(self, doy, depth, lat, lon, var):
        
        subset, dims = self.crop(doy, depth, lat, lon, var)

        # Subset contains everything requested. No need to interpolate.
        if np.all([d in dims['time'] for d in doy]) & \
                np.all([z in dims['depth'] for z in depth]) & \
                np.all([y in dims['lat'] for y in lat]) & \
                np.all([x in dims['lon'] for x in lon]):
                    dn = np.nonzero([d in doy for d in dims['time']])[0]
                    zn = np.nonzero([z in depth for z in dims['depth']])[0]
                    yn = np.nonzero([y in lat for y in dims['lat']])[0]
                    xn = np.nonzero([x in lon for x in dims['lon']])[0]
                    output = {}
                    for v in subset:
                        # output[v] = subset[v][dn, zn, yn, xn]
                        # Seriously that this is the way to do it?!!??
                        output[v] = subset[v][:, :, :, xn][:, :, yn][:, zn][dn]
                    return output

        output = {}
        for v in var:
            output[v] = ma.masked_all(
                    (doy.size, depth.size, lat.size, lon.size),
                    dtype=subset[v].dtype)

            # These interpolators don't understand Masked Arrays, but do NaN
            if subset[v].dtype in ['int32']:
                subset[v] = subset[v].astype('f')
            subset[v][ma.getmaskarray(subset[v])] = np.nan
            subset[v] = subset[v].data

        # First linear interpolate on time.
        if not (doy == dims['time']).all():
            for v in subset.keys():
                f = interp1d(dims['time'], subset[v], axis=0)
                subset[v] = f(doy)
            dims['time'] = np.atleast_1d(doy)

        if not (np.all(lat == dims['lat']) and np.all(lon == dims['lon'])):
            # Lat x Lon target coordinates are the same for all time and depth.
            points_out = []
            for latn in lat:
                for lonn in lon:
                    points_out.append([latn, lonn])
            points_out = np.array(points_out)

            # Interpolate on X/Y plane
            for v in subset:
                tmp = np.nan * np.ones(
                        (doy.size, dims['depth'].size, lat.size, lon.size),
                        dtype=subset[v].dtype)
                for nt in range(doy.size):
                    for nz in range(dims['depth'].size):
                        data = subset[v][nt, nz]
                        # The valid data
                        idx = np.nonzero(~np.isnan(data))
                        if idx[0].size > 0:
                            points = np.array([
                                dims['lat'][idx[0]], dims['lon'][idx[1]]]).T
                            values = data[idx]
                            # Interpolate along the dimensions that have more than
                            #   one position, otherwise it means that the output
                            #   is exactly on that coordinate.
                            #ind = np.array([np.unique(points[:, i]).size > 1
                            #    for i in range(points.shape[1])])
                            #assert ind.any()

                            try:
                                values_out = griddata(
                                    #np.atleast_1d(np.squeeze(points[:, ind])),
                                    np.atleast_1d(np.squeeze(points)),
                                    values,
                                    #np.atleast_1d(np.squeeze(points_out[:, ind])))
                                    np.atleast_1d(np.squeeze(points_out)))
                            except:
                                values_out = []
                                for p in points_out:
                                    try:
                                        values_out.append(griddata(
                                            np.atleast_1d(np.squeeze(points)),
                                            values,
                                            np.atleast_1d(np.squeeze(
                                                p))))
                                    except:
                                        values_out.append(np.nan)
                                values_out = np.array(values_out)

                            # Remap the interpolated value back into a 4D array
                            idx = np.isfinite(values_out)
                            for [y, x], out in zip(
                                    points_out[idx], values_out[idx]):
                                tmp[nt, nz, y==lat, x==lon] = out
                subset[v] = tmp

        # Interpolate on z
        same_depth = (np.shape(depth) == dims['depth'].shape) and \
                np.allclose(depth, dims['depth'])
        if not same_depth:
            for v in list(subset.keys()):
                try:
                    f = interp1d(dims['depth'], subset[v], axis=1, bounds_error=False)
                    # interp1d does not handle Masked Arrays
                    subset[v] = f(np.array(depth))
                except:
                    print("Fail to interpolate '%s' in depth" % v)
                    del(subset[v])

        for v in subset:
            if output[v].dtype in ['int32']:
                subset[v] = np.round(subset[v])
            output[v][:] = ma.fix_invalid(subset[v][:])

        return output