This is a higher speed (if messier) version of wrap
184425
def wrap(txt, line_len = 76)
      res = ""
      sp = 0
      ep = txt.length
      while sp < ep
        # scan back for a space
        p = sp + line_len - 1
        if p >= ep
          p = ep
        else
          while p > sp and txt[p] != ?\s
            p -= 1
          end
          if p <= sp
            p = sp + line_len
            while p < ep and txt[p] != ?\s
              p += 1
            end
          end
        end
        res << txt[sp...p] << "\n"
        sp = p
        sp += 1 while sp < ep and txt[sp] == ?\s
      end
      res
    end
280985
function wrap(fn, wrapper) {
        if (!wrapper)
            wrapper = function(f){ f.apply(this, slice.call(arguments, 1)) }

        return partial(wrapper, fn)
    }
647059
def wrap(v):
    

    type_ = _get(v, CLASS)

    if type_ is dict:
        m = object.__new__(Data)
        _set(m, SLOT, v)
        return m
    elif type_ is none_type:
        return Null
    elif type_ is list:
        return FlatList(v)
    elif type_ in generator_types:
        return FlatList(list(unwrap(vv) for vv in v))
    else:
        return v
1051938
def _wrap(x, serializeFunc, encodeFunc=base64.urlsafe_b64encode, compress=True):
    
    return encodeFunc(serializeFunc(x, compress))
994746
public static JCGLTextureWrapT textureWrapTFromGL(
    final int wrap)
  {
    switch (wrap) {
      case GL12.GL_CLAMP_TO_EDGE:
        return JCGLTextureWrapT.TEXTURE_WRAP_CLAMP_TO_EDGE;
      case GL11.GL_REPEAT:
        return JCGLTextureWrapT.TEXTURE_WRAP_REPEAT;
      case GL14.GL_MIRRORED_REPEAT:
        return JCGLTextureWrapT.TEXTURE_WRAP_REPEAT_MIRRORED;
      default:
        throw new UnreachableCodeException();
    }
  }
702125
function wrapify(fn, before = noop, after = noop) {
  return function(...args) {
    before.call(this);
    var ret = fn.call(this, ...args);
    after.call(this);
    return ret;
  };
}
852027
def GetChunk(time, breakpoints, b, mask=[]):
    '''
    

    '''

    M = np.delete(np.arange(len(time)), mask, axis=0)
    if b > 0:
        res = M[(M > breakpoints[b - 1]) & (M <= breakpoints[b])]
    else:
        res = M[M <= breakpoints[b]]
    return res
1152526
def wrapcache(timeout = -1, adapter = MemoryAdapter):
	'''
	
	'''
	def _wrapcache(function):
		@wraps(function)
		def __wrapcache(*args, **kws):
			hash_key = _wrap_key(function, args, kws)
			try:
				adapter_instance = adapter()
				return pickle.loads(adapter_instance.get(hash_key))
			except CacheExpiredException:
				#timeout
				value = function(*args, **kws)
				set(hash_key, value, timeout, adapter)
				return value
		return __wrapcache
	return _wrapcache
177798
def dask_rolling_wrapper(moving_func, a, window, min_count=None, axis=-1):
    ''''''
    dtype, fill_value = dtypes.maybe_promote(a.dtype)
    a = a.astype(dtype)
    # inputs for overlap
    if axis < 0:
        axis = a.ndim + axis
    depth = {d: 0 for d in range(a.ndim)}
    depth[axis] = (window + 1) // 2
    boundary = {d: fill_value for d in range(a.ndim)}
    # Create overlap array.
    ag = overlap(a, depth=depth, boundary=boundary)
    # apply rolling func
    out = ag.map_blocks(moving_func, window, min_count=min_count,
                        axis=axis, dtype=a.dtype)
    # trim array
    result = trim_internal(out, depth)
    return result
228880
def fastMean(img, f=10, inplace=False):
    '''
    
    '''
    s0,s1 = img.shape[:2]
    ss0 = int(round(s0/f))
    ss1 = int(round(s1/f))

    small = cv2.resize(img,(ss1,ss0), interpolation=cv2.INTER_AREA)
        #bigger
    k = {'interpolation':cv2.INTER_LINEAR}
    if inplace:
        k['dst']=img
    return cv2.resize(small,(s1,s0), **k)
169905
def _slow_calcbinflux(len_binwave, i_beg, i_end, avflux, deltaw):
    
    binflux = np.empty(shape=(len_binwave, ), dtype=np.float64)
    intwave = np.empty(shape=(len_binwave, ), dtype=np.float64)

    # Note that, like all Python striding, the range over which
    # we integrate is [first:last).
    for i in range(len(i_beg)):
        first = i_beg[i]
        last = i_end[i]
        cur_dw = deltaw[first:last]
        intwave[i] = cur_dw.sum()
        binflux[i] = np.sum(avflux[first:last] * cur_dw) / intwave[i]

    return binflux, intwave
978759
def wrap_setup(self, class_name, typ, with_async=False):
        """"""
        equivalence = self.equivalence[typ]
        return [
              (NEWLINE, '\n')
            , (NAME, class_name)
            , (OP, '.')
            , (NAME, equivalence)
            , (OP, '=')
            , (NAME, "%snoy_wrap_%s" % ('async_' if with_async else '', equivalence))
            , (OP, "(")
            , (NAME, class_name)
            , (OP, ',')
            , (NAME, class_name)
            , (OP, '.')
            , (NAME, equivalence)
            , (OP, ")")
            ]
1112626
function wrapper(my) {

  var finished = require('on-finished');

  var __denominator = my.denominator;
  var __byte = my.byte;
  var __time = my.time;
  var __out = my.out;

  /**
   * response
   * 
   * @function wrapper
   * @param {Object} socket - client socket
   * @param {Array} start - start time
   * @return {String}
   */
  function response(socket, start) {

    var diff = process.hrtime(start);
    var nanoseconds = diff[0] * 1e9 + diff[1];
    var bytes = socket.bytesWritten - ~~socket.transferRateBytesWritten;
    var data = (bytes * __byte) / __denominator;

    socket.transferRateBytesWritten = socket.bytesWritten; // keep-alive socket
    return (data / (nanoseconds / __time)).toFixed(2) + __out;
  }

  /**
   * request
   * 
   * @function wrapper
   * @param {Object} socket - client socket
   * @param {Array} start - start time
   * @return {String}
   */
  function request(socket, start) {

    var diff = process.hrtime(start);
    var nanoseconds = diff[0] * 1e9 + diff[1];
    var bytes = socket.bytesRead - ~~socket.transferRateBytesRead;
    var data = (bytes * __byte) / __denominator;

    socket.transferRateBytesRead = socket.bytesRead; // keep-alive socket
    return (data / (nanoseconds / __time)).toFixed(2) + __out;
  }

  if (my.response) {

    /**
     * rate
     * 
     * @function rate
     * @param {Object} req - client request
     * @param {Object} res - client response
     * @param {Array} start - start time
     * @return {String}
     */
    return function rate(req, res, start) {

      if (typeof req !== 'object') {
        throw new TypeError('req required');
      } else if (typeof res !== 'object') {
        throw new TypeError('res required');
      } else if (Array.isArray(start) === false) {
        throw new TypeError('start required');
      }

      /*
       * single request
       */
      if (finished.isFinished(res)) {
        var socket = res.socket || req.socket;
        var data = response(socket, start);
        req.transferRate = res.transferRate = data;
        return data;
      }

      /*
       * chunk
       */
      finished(res, function(err, res) {

        if (!err) {
          var socket = res.req.socket;
          var data = response(socket, start);
          req.transferRate = res.transferRate = data;
        }
      });
    };

  } else {

    /**
     * rate
     * 
     * @function rate
     * @param {Object} req - client request
     * @param {Object} res - client response
     * @param {Array} start - start time
     * @return {String}
     */
    return function rate(req, res, start) {

      if (typeof req !== 'object') {
        throw new TypeError('req required');
      } else if (typeof res !== 'object') {
        throw new TypeError('res required');
      } else if (Array.isArray(start) === false) {
        throw new TypeError('start required');
      }

      /*
       * single request
       */
      if (finished.isFinished(req)) {
        var socket = req.socket;
        var data = request(socket, start);
        req.transferRate = res.transferRate = data;
        return data;
      }

      /*
       * chunk
       */
      finished(req, function(err, req) {

        if (!err) {
          var socket = req.socket;
          var data = request(socket, start);
          req.transferRate = res.transferRate = data;
        }
      });
    };

  }
}
1209266
def advanced_wrap(f, wrapper):
    
    f_sig = list(inspect.getargspec(f))
    wrap_sig = list(inspect.getargspec(wrapper))

    # Update the keyword arguments of the wrapper
    if f_sig[3] is None or f_sig[3] == []:
        f_sig[3], f_kwargs = [], []
    else:
        f_kwargs = f_sig[0][-len(f_sig[3]):]

    for key, default in zip(f_kwargs, f_sig[3]):
        wrap_sig[0].append(key)
        wrap_sig[3] = wrap_sig[3] + (default, )

    wrap_sig[2] = None  # Remove kwargs
    src = "lambda %s: " % (inspect.formatargspec(*wrap_sig)[1:-1])
    new_args = inspect.formatargspec(
        wrap_sig[0], wrap_sig[1], wrap_sig[2], f_kwargs,
        formatvalue=lambda x: '=' + x)
    src += 'wrapper%s\n' % new_args

    decorated = eval(src, locals())
    decorated.func = f
    return update_wrapper(decorated, f)
70689
function amdWrap(factoryCode, deps) {
        var deps = deps.map(function (dep) {
            return "'" + dep + "'";
        });
        return AMD_TEMPLATE.START +
            deps.join(',') +
            AMD_TEMPLATE.MIDDLE +
            factoryCode +
            AMD_TEMPLATE.END;
    }
640821
def _bottleneck_reduce(cls, func):
        

        def wrapped_func(self, **kwargs):
            from .dataarray import DataArray

            # bottleneck doesn't allow min_count to be 0, although it should
            # work the same as if min_count = 1
            if self.min_periods is not None and self.min_periods == 0:
                min_count = 1
            else:
                min_count = self.min_periods

            axis = self.obj.get_axis_num(self.dim)

            padded = self.obj.variable
            if self.center:
                if (LooseVersion(np.__version__) < LooseVersion('1.13') and
                        self.obj.dtype.kind == 'b'):
                    # with numpy < 1.13 bottleneck cannot handle np.nan-Boolean
                    # mixed array correctly. We cast boolean array to float.
                    padded = padded.astype(float)

                if isinstance(padded.data, dask_array_type):
                    # Workaround to make the padded chunk size is larger than
                    # self.window-1
                    shift = - (self.window + 1) // 2
                    offset = (self.window - 1) // 2
                    valid = (slice(None), ) * axis + (
                        slice(offset, offset + self.obj.shape[axis]), )
                else:
                    shift = (-self.window // 2) + 1
                    valid = (slice(None), ) * axis + (slice(-shift, None), )
                padded = padded.pad_with_fill_value({self.dim: (0, -shift)})

            if isinstance(padded.data, dask_array_type):
                values = dask_rolling_wrapper(func, padded,
                                              window=self.window,
                                              min_count=min_count,
                                              axis=axis)
            else:
                values = func(padded.data, window=self.window,
                              min_count=min_count, axis=axis)

            if self.center:
                values = values[valid]
            result = DataArray(values, self.obj.coords)

            return result
        return wrapped_func
1313545
def sliding_impl(wrap, size, step, sequence):
    
    i = 0
    n = len(sequence)
    while i + size <= n or (step != 1 and i < n):
        yield wrap(sequence[i: i + size])
        i += step