Wrapper around rebin that actually rebins 2 by 2
973847
def rebin2x2(a):
    
    inshape = np.array(a.shape)
    if not (inshape % 2 == np.zeros(2)).all(): # Modulo check to see if size is even
        raise RuntimeError, "I want even image shapes !"
        
    return rebin(a, inshape/2)
1227112
def _rebind_variables(self, new_inputs):
        
        expr = self._expr

        # If we have 11+ variables, some of our variable names may be
        # substrings of other variable names. For example, we might have x_1,
        # x_10, and x_100. By enumerating in reverse order, we ensure that
        # every variable name which is a substring of another variable name is
        # processed after the variable of which it is a substring. This
        # guarantees that the substitution of any given variable index only
        # ever affects exactly its own index. For example, if we have variables
        # with indices going up to 100, we will process all of the x_1xx names
        # before x_1x, which will be before x_1, so the substitution of x_1
        # will not affect x_1x, which will not affect x_1xx.
        for idx, input_ in reversed(list(enumerate(self.inputs))):
            old_varname = "x_%d" % idx
            # Temporarily rebind to x_temp_N so that we don't overwrite the
            # same value multiple times.
            temp_new_varname = "x_temp_%d" % new_inputs.index(input_)
            expr = expr.replace(old_varname, temp_new_varname)
        # Clear out the temp variables now that we've finished iteration.
        return expr.replace("_temp_", "_")
466824
def swapWH(self):
        
        width = self.width
        self.width = self.height
        self.height = width
1236671
def rewrap(s, width=COLS):
    
    s = ' '.join([l.strip() for l in s.strip().split('\n')])
    return '\n'.join(textwrap.wrap(s, width))
677700
def _irshift(self, n):
        """"""
        assert 0 < n <= self.len
        self._prepend(Bits(n))
        self._truncateend(n)
        return self
674632
function addAlignment(x, y) {
    var i;

    frameBuffer[x + width * y] = 1;

    for (i = -2; i < 2; i++) {
      frameBuffer[(x + i)     + width * (y - 2)]     = 1;
      frameBuffer[(x - 2)     + width * (y + i + 1)] = 1;
      frameBuffer[(x + 2)     + width * (y + i)]     = 1;
      frameBuffer[(x + i + 1) + width * (y + 2)]     = 1;
    }

    for (i = 0; i < 2; i++) {
      setMask(x - 1, y + i);
      setMask(x + 1, y - i);
      setMask(x - i, y - 1);
      setMask(x + i, y + 1);
    }
  }
508236
def ydtick(self, dtick, index=1):
        """"""
        self.layout['yaxis' + str(index)]['dtick'] = dtick
        return self
375487
def rewrap_long(s, width=COLS):
    
    paras = s.split('\n\n')
    return '\n\n'.join(rewrap(p) for p in paras)
175038
def ro_rw_to_binds(ro, rw):
    
    out = {}
    if ro:
        for localdir, binddir in ro.iteritems():
            out[localdir] = {'bind': binddir, 'ro': True}
    if rw:
        for localdir, binddir in rw.iteritems():
            out[localdir] = {'bind': binddir, 'ro': False}
    return out
658704
def keyevent2tuple(event):
    """"""
    return (event.type(), event.key(), event.modifiers(), event.text(),
            event.isAutoRepeat(), event.count())
161916
def rev_twos_comp_repr(val, bitwidth):
    
    valbl = val.bit_length()
    if bitwidth < val.bit_length() or val == 2**(bitwidth-1):
        raise pyrtl.PyrtlError("please choose a larger target bitwidth")
    if bitwidth == valbl:  # MSB is a 1, value is negative
        return -((~val & (2**bitwidth-1)) + 1)  # flip the bits, add one, and make negative
    else:
        return val
1368719
def dec2bin(s):
    
    if not isinstance(s, int):
        num = int(s)
    else:
        num = s
    mid = []
    while True:
        if num == 0:
            break
        num, rem = divmod(num, 2)
        mid.append(base[rem])

    return ''.join([str(x) for x in mid[::-1]])
838264
def rewrap_bytes(data):
    '''
    '''
    return b'\n'.join(
        data[index:index+70] for index in range(0, len(data), 70)
    )
1016690
def shrink_wrap(self):
        """"""

        self.frame.size = (self.text_size[0] + self.padding[0] * 2,
                           self.text_size[1] + self.padding[1] * 2)
1083650
def _remap_pair(self, operation, src, dst, *args, **kw):
        """"""
        return (
            self._remap_input(operation + '-from', src, *args, **kw),
            self._remap_input(operation + '-to', dst, *args, **kw)
        )
314042
void zeroPad2(StringBuilder b, int value, int width) {
    switch (width) {
      case 2:
        if (value < 10) {
          b.append('0');
        }
        // fall through

      case 1:
        b.append(value);
        break;
    }
  }
870430
function interpolation2(prefix, v0, i0, v1, suffix) {
    var different = bindingUpdated2(v0, v1);
    return different ? prefix + stringify$1(v0) + i0 + stringify$1(v1) + suffix : NO_CHANGE;
}