Returns the code to produce py ctypes for the indices of the specified parameter
    that has D > 0.
429041
def _py_indices(parameter, lparams, tab):
    
    if parameter.D > 0 and ":" in parameter.dimension:
        if "in" in parameter.direction:
            indexstr = "{0}_{1:d} = c_int({0}_a.shape[{1:d}])"
        else:
            indexstr = "{0}_{1:d} = c_int(0)"
        lparams.extend(["byref({}_{})".format(parameter.lname, i) for i in range(parameter.D)])
        joinstr = "\n" + tab
        blank = True if parameter.direction == "(out)" else False
        return (joinstr.join([indexstr.format(parameter.lname, i)
                              for i in range(parameter.D)]), blank)
61221
def _normalize_numpy_indices(i):
    """"""
    if isinstance(i, np.ndarray):
        if i.dtype == bool:
            i = tuple(j.tolist() for j in i.nonzero())
        elif i.dtype == int:
            i = i.tolist()
    return i
199037
def _get_lattice_parameters(lattice):
    

    return np.array(np.sqrt(np.dot(lattice.T, lattice).diagonal()),
                    dtype='double')
263690
def to_int(d, key, default_to_zero=False, default=None, required=True):
    
    value = d.get(key) or default
    if (value in ["", None]) and default_to_zero:
        return 0
    if value is None:
        if required:
            raise ParseError("Unable to read %s from %s" % (key, d))
    else:
        return int(value)
158037
def get_variable_ddi(name, shape, initial_value, dtype=tf.float32, init=False,
                     trainable=True):
  """"""
  # If init is a tf bool: w is assigned dynamically at runtime.
  # If init is a python bool: then w is determined during graph construction.
  w = tf.get_variable(name, shape, dtype, None, trainable=trainable)
  if isinstance(init, bool):
    if init:
      return assign(w, initial_value)
    return w
  else:
    return tf.cond(init, lambda: assign(w, initial_value), lambda: w)
1126972
def _str_dtype(dtype):
        
        assert dtype.byteorder != '>'
        if dtype.kind == 'i':
            assert dtype.itemsize == 8
            return 'int64'
        elif dtype.kind == 'f':
            assert dtype.itemsize == 8
            return 'float64'
        elif dtype.kind == 'U':
            return 'U%d' % (dtype.itemsize / 4)
        else:
            raise UnhandledDtypeException("Bad dtype '%s'" % dtype)
665627
def get_c_option_index(args):
    
    try:
        ind_c = args.index('-c')
    except ValueError:
        return -1
    else:
        for i in range(1, ind_c):
            if not args[i].startswith('-'):
                # there is an arg without "-" before "-c", so it's not an interpreter's option
                return -1
        return ind_c
319313
def n_hot(ids, c):
    '''
    
    '''
    res = np.zeros((c,), dtype=np.float32)
    res[ids] = 1
    return res
1267565
def _ctypes_regular(parameter):
    
    if ("pointer" in parameter.modifiers or "allocatable" in parameter.modifiers
        or "target" in parameter.modifiers or parameter.dtype == "logical"):
        return (parameter.definition(local=True), False)
554787
def guess_param_types(**kwargs):
    
    params = {}
    for k, v in kwargs.items():
        kws = dict(default=v, constant=True)
        if isinstance(v, Parameter):
            params[k] = v
        elif isinstance(v, dt_types):
            params[k] = Date(**kws)
        elif isinstance(v, bool):
            params[k] = Boolean(**kws)
        elif isinstance(v, int):
            params[k] = Integer(**kws)
        elif isinstance(v, float):
            params[k] = Number(**kws)
        elif isinstance(v, str):
            params[k] = String(**kws)
        elif isinstance(v, dict):
            params[k] = Dict(**kws)
        elif isinstance(v, tuple):
            if all(_is_number(el) for el in v):
                params[k] = NumericTuple(**kws)
            elif all(isinstance(el. dt_types) for el in v) and len(v)==2:
                params[k] = DateRange(**kws)
            else:
                params[k] = Tuple(**kws)
        elif isinstance(v, list):
            params[k] = List(**kws)
        elif isinstance(v, np.ndarray):
            params[k] = Array(**kws)
        else:
            from pandas import DataFrame as pdDFrame
            from pandas import Series as pdSeries

            if isinstance(v, pdDFrame):
                params[k] = DataFrame(**kws)
            elif isinstance(v, pdSeries):
                params[k] = Series(**kws)
            else:
                params[k] = Parameter(**kws)

    return params
480222
def drange(v0, v1, d):
    """"""
    assert v0 < v1
    return xrange(int(v0)//d, int(v1+d)//d)
904932
def pytype_to_ctype(t):
    
    if isinstance(t, List):
        return 'pythonic::types::list<{0}>'.format(
            pytype_to_ctype(t.__args__[0])
        )
    elif isinstance(t, Set):
        return 'pythonic::types::set<{0}>'.format(
            pytype_to_ctype(t.__args__[0])
        )
    elif isinstance(t, Dict):
        tkey, tvalue = t.__args__
        return 'pythonic::types::dict<{0},{1}>'.format(pytype_to_ctype(tkey),
                                                       pytype_to_ctype(tvalue))
    elif isinstance(t, Tuple):
        return 'decltype(pythonic::types::make_tuple({0}))'.format(
            ", ".join('std::declval<{}>()'.format(pytype_to_ctype(p))
                      for p in t.__args__)
        )
    elif isinstance(t, NDArray):
        dtype = pytype_to_ctype(t.__args__[0])
        ndim = len(t.__args__) - 1
        shapes = ','.join(('long'
                           if s.stop == -1 or s.stop is None
                           else 'std::integral_constant<long, {}>'.format(
                               s.stop)
                           ) for s in t.__args__[1:])
        pshape = 'pythonic::types::pshape<{0}>'.format(shapes)
        arr = 'pythonic::types::ndarray<{0},{1}>'.format(
                    dtype, pshape)
        if t.__args__[1].start == -1:
            return 'pythonic::types::numpy_texpr<{0}>'.format(arr)
        elif any(s.step is not None and s.step < 0 for s in t.__args__[1:]):
            slices = ", ".join(['pythonic::types::normalized_slice'] * ndim)
            return 'pythonic::types::numpy_gexpr<{0},{1}>'.format(arr, slices)
        else:
            return arr
    elif isinstance(t, Pointer):
        return 'pythonic::types::pointer<{0}>'.format(
            pytype_to_ctype(t.__args__[0])
        )
    elif isinstance(t, Fun):
        return 'pythonic::types::cfun<{0}({1})>'.format(
            pytype_to_ctype(t.__args__[-1]),
            ", ".join(pytype_to_ctype(arg) for arg in t.__args__[:-1]),
        )
    elif t in PYTYPE_TO_CTYPE_TABLE:
        return PYTYPE_TO_CTYPE_TABLE[t]
    else:
        raise NotImplementedError("{0}:{1}".format(type(t), t))
76230
def Get_RpRs(d, **kwargs):
    '''
    

    '''
    if ps is None:
            raise Exception("Unable to import `pysyzygy`.")

    def Depth(RpRs, **kwargs):
        return 1 - ps.Transit(RpRs=RpRs, **kwargs)([kwargs.get('t0', 0.)])

    def DiffSq(r):
        return 1.e10 * (d - Depth(r, **kwargs)) ** 2

    return fmin(DiffSq, [np.sqrt(d)], disp=False)
328532
def _get_pdi(cls, df, windows):
        
        window = cls.get_only_one_positive_int(windows)
        pdm_column = 'pdm_{}'.format(window)
        tr_column = 'atr_{}'.format(window)
        pdi_column = 'pdi_{}'.format(window)
        df[pdi_column] = df[pdm_column] / df[tr_column] * 100
        return df[pdi_column]
790306
def get_py_dtype(np_dtype):
    '''
    
    '''
    if np_dtype.type == np.object_:
        return object
    elif hasattr(np_dtype.type(0), 'item'):
        return type(np_dtype.type(0).item())
    else:
        return type(np_dtype.type(0))
992874
def _ctypes_ex_assign(executable):
    
    result = []
    for p in executable.ordered_parameters:
        _ctypes_code_parameter(result, p, "assign")

    if type(executable).__name__ == "Function":
        _ctypes_code_parameter(result, executable, "assign")

    return result
990410
def getDXGIOutputInfo(self):
        

        fn = self.function_table.getDXGIOutputInfo
        pnAdapterIndex = c_int32()
        fn(byref(pnAdapterIndex))
        return pnAdapterIndex.value