Returns z if type is 1 or 2 and z is explicitly defined in kwargs.
        Otherwise, raises TypeError.
491555
def _get_z(self, kwargs):
        '''
        
        '''
        if self._type == 1 or self._type == 2:
            if 'z' in kwargs:
                return round(float(kwargs['z']), 6)
            elif self._element_z in kwargs:
                return round(float(kwargs[self._element_z]), 6)
        raise TypeError()
589906
def type_check(arg_name, pos, reqd_type):
    

    def decorator(fn):

        # brevity compromised in favour of readability
        def logic(*args, **kwargs):
            arg_count = len(args)
            if arg_count:
                if pos < arg_count:
                    if isinstance(args[pos], reqd_type):
                        return fn(*args, **kwargs)
                    else:
                        raise TypeError("'{0}' at position {1} not of type {2}".format(args[pos], pos, reqd_type))
                else:
                    if arg_name in kwargs:
                        value = kwargs[arg_name]
                        if isinstance(value, reqd_type):
                            return fn(*args, **kwargs)
                        else:
                            raise TypeError("'{0}' is not of type {1}".format(arg_name, reqd_type))
                    else:
                        # partially applied functions because of incomplete args, let python handle this
                        return fn(*args, **kwargs)
            else:
                if arg_name in kwargs:
                    value = kwargs[arg_name]
                    if isinstance(value, reqd_type):
                        return fn(*args, **kwargs)
                else:
                    raise TypeError("'{0}' is not of type {1}".format(arg_name, reqd_type))

        return logic

    return decorator
666986
def is_primitive(self):
        """"""
        if is_py2:
            return isinstance(
                self.val, 
                (
                    types.NoneType,
                    types.BooleanType,
                    types.IntType,
                    types.LongType,
                    types.FloatType
                )
            )

        else:
            return isinstance(
                self.val,
                (
                    type(None),
                    bool,
                    int,
                    float
                )
            )
251798
function (type, number1, number2) {
      var result;

      number1 = helper.number(number1);
      number2 = helper.number(number2);

      if (isNaN(number1) || isNaN(number2)) {

        if (number1[0] === '=' || number2[0] === '=') {
          throw Error('NEED_UPDATE');
        }

        throw Error('VALUE');
      }

      switch (type) {
        case '+':
          result = number1 + number2;
          break;
        case '-':
          result = number1 - number2;
          break;
        case '/':
          result = number1 / number2;
          if (result == Infinity) {
            throw Error('DIV_ZERO');
          } else if (isNaN(result)) {
            throw Error('VALUE');
          }
          break;
        case '*':
          result = number1 * number2;
          break;
        case '^':
          result = Math.pow(number1, number2);
          break;
      }

      return result;
    }
840372
def typed_range(type_func, minimum, maximum):
    
    @functools.wraps(type_func)
    def inner(string):
        result = type_func(string)
        if not result >= minimum and result <= maximum:
            raise argparse.ArgumentTypeError(
                    "Please provide a value between {0} and {1}".format(
                        minimum, maximum))
        return result
    return inner
536413
def _check_inputs(z, m):
    """"""
    try:
        nz = len(z)
        z = np.array(z)
    except TypeError:
        z = np.array([z])
        nz = len(z)
    try:
        nm = len(m)
        m = np.array(m)
    except TypeError:
        m = np.array([m])
        nm = len(m)

    if (z < 0).any() or (m < 0).any():
        raise ValueError('z and m must be positive')

    if nz != nm and nz > 1 and nm > 1:
        raise ValueError('z and m arrays must be either equal in length, \
                          OR of different length with one of length 1.')

    else:
        if type(z) != np.ndarray:
            z = np.array(z)
        if type(m) != np.ndarray:
            m = np.array(m)

        return z, m
20328
def _check_not_tuple_of_2_elements(obj, obj_name='obj'):
    """"""
    if not isinstance(obj, tuple) or len(obj) != 2:
        raise TypeError('%s must be a tuple of 2 elements.' % obj_name)
1274170
def _op_generic_Clz(self, args):
        """"""
        wtf_expr = claripy.BVV(self._from_size, self._from_size)
        for a in range(self._from_size):
            bit = claripy.Extract(a, a, args[0])
            wtf_expr = claripy.If(bit==1, claripy.BVV(self._from_size-a-1, self._from_size), wtf_expr)
        return wtf_expr
151493
def _dom_class(self, obj1, obj2):
        
        if isinstance(obj1, Double) or isinstance(obj2, Double):
            return Double
        if isinstance(obj1, Float) or isinstance(obj2, Float):
            return Float
335115
def sometimes(fn):
    

    def wrapped(*args, **kwargs):
        wrapped.x += 1
        if wrapped.x % 2 == 1:
            return fn(*args, **kwargs)

    wrapped.x = 0
    return wrapped
1130434
def Then2(self, f, arg1, *args, **kwargs):
        
        args = (arg1,) + args
        return self.ThenAt(2, f, *args, **kwargs)
343917
def z2r(z):
    
    with np.errstate(invalid='ignore', divide='ignore'):
        return (np.exp(2 * z) - 1) / (np.exp(2 * z) + 1)
1301057
def check_type(*args, **kwargs):
    ''' 
    '''
    args = tuple(x if isinstance(x, collections.Iterable) else (x,) for x in args)
    kwargs = {x: kwargs[x] if isinstance(kwargs[x], collections.Iterable) else (kwargs[x],) for x in kwargs}

    def decorate(func):
        types = args
        kwtypes = kwargs
        gi = "Got <{}> instead"
        errmsg1 = "to be of type <{}>. " + gi
        errmsg2 = "to be one of type ({}). " + gi
        errar = "{}:{} expected '{}' "
        errkw = "{}:{} expected {} "

        def check(*ar, **kw):
            line = inspect.getouterframes(inspect.currentframe())[1][2]
            fname = os.path.basename(inspect.getouterframes(inspect.currentframe())[1][1])

            for arg, type_ in zip(ar, types):
                if type(arg) not in type_:
                    if len(type_) == 1:
                        raise TypeError((errar + errmsg1).format(fname, line, arg, type_[0].__name__,
                                                                 type(arg).__name__))
                    else:
                        raise TypeError((errar + errmsg2).format(fname, line, arg,
                                                                 ', '.join('<%s>' % x.__name__ for x in type_),
                                                                 type(arg).__name__))
            for kwarg in kw:
                if kwtypes.get(kwarg, None) is None:
                    continue
                if type(kw[kwarg]) not in kwtypes[kwarg]:
                    if len(kwtypes[kwarg]) == 1:
                        raise TypeError((errkw + errmsg1).format(fname, line, kwarg, kwtypes[kwarg][0].__name__,
                                                                 type(kw[kwarg]).__name__))
                    else:
                        raise TypeError((errkw + errmsg2).format(
                            fname,
                            line,
                            kwarg,
                            ', '.join('<%s>' % x.__name__ for x in kwtypes[kwarg]),
                            type(kw[kwarg]).__name__)
                        )

            return func(*ar, **kw)

        return check

    return decorate
1339094
def std(self, bias=False, *args, **kwargs):
        
        nv.validate_window_func('std', args, kwargs)
        return _zsqrt(self.var(bias=bias, **kwargs))
211544
def zfind(cls, **kwargs):
        
        assert len(kwargs) == 1
        fldcond = kwargs.keys()[0].split('__')
        fld = fldcond[0]
        f = cls.__dict__[fld]
        val = kwargs.values()[0]
        if isinstance(val, tuple):
            assert len(val) == 2
            val = (f.typecast_for_write(val[0]), f.typecast_for_write(val[1]))
        else:
            val = f.typecast_for_write(val)
        if len(fldcond) == 1:
            return f.zindex.zfind(eq = val)
        else:
            cond = fldcond[1]
            return f.zindex.zfind(**{cond: val})
1262983
def numberp(v):
    """"""
    return (not(isinstance(v, bool)) and
            (isinstance(v, int) or isinstance(v, float)))
283326
def find(self, **kwargs):
        

        if len(kwargs) != 1:
            raise ValueError("One and only one keyword argument accepted")

        key = list(kwargs.keys())[0]
        value = list(kwargs.values())[0]
        ret = None
        for row in self.values():
            if row[key] == value:
                ret = row
                break
        return ret