This prepares EC and converts from contig_id to an index.
17261
def prepare_ec(oo, sizes, M):
    
    tour = range(len(oo))
    tour_sizes = np.array([sizes.sizes[x] for x in oo])
    tour_M = M[oo, :][:, oo]
    return tour, tour_sizes, tour_M
1274297
def create_index_from_fieldspec(self,
                                    table: str,
                                    fieldspec: FIELDSPEC_TYPE,
                                    indexname: str = None) -> None:
        """"""
        if "indexed" in fieldspec and fieldspec["indexed"]:
            if "index_nchar" in fieldspec:
                nchar = fieldspec["index_nchar"]
            else:
                nchar = None
            self.create_index(table, fieldspec["name"], nchar,
                              indexname=indexname)
937755
def generate_index(self, schemas):
        ''''''
        params = {'schemas': sorted(schemas, key=lambda x: x.object_name),
                  'project': self.project_name,
                  'title': '{}: Database schema documentation'\
                  .format(self.project_name)}
        template = self.lookup.get_template('index.mako')
        html = template.render_unicode(**params)
        return html
261112
private static long toArrayIndex(String id)
    {
        long index = toArrayIndex(ScriptRuntime.toNumber(id));
        // Assume that ScriptRuntime.toString(index) is the same
        // as java.lang.Long.toString(index) for long
        if (Long.toString(index).equals(id)) {
            return index;
        }
        return -1;
    }
1048693
def index_to_widget(self, idx):
        """"""
        nchild = self.widget.get_nth_page(idx)
        return self._native_to_child(nchild)
647370
def prepare(cls, session, pkgen, items):
        
        for item in cls.merge(session, items):
            if hasattr(item, "id"):
                item.id.resolve(id=pkgen.get(cls), is_new=True)
            yield cls.to_dict(item)
1222601
def to_index(self, index_type, index_name, includes=None):
        
        return IndexField(self.name, self.data_type, index_type, index_name, includes)
697071
def ec_init(spec):
    

    kb = KeyBundle(keytype="EC")
    if 'use' in spec:
        for use in spec["use"]:
            eck = new_ec_key(crv=spec['crv'], use=use)
            kb.append(eck)
    else:
        eck = new_ec_key(crv=spec['crv'])
        kb.append(eck)

    return kb
1135614
def index_to_coords(index, shape):
    ''''''
    coords = []
    for i in xrange(1, len(shape)):
        divisor = int(np.product(shape[i:]))
        value = index // divisor
        coords.append(value)
        index -= value * divisor
    coords.append(index)
    return tuple(coords)
645594
def _id_remapper(orig, new):
    
    new_chrom_to_index = {}
    for i_n, (chr_n, _) in enumerate(new):
        new_chrom_to_index[chr_n] = i_n
    remap_indexes = {}
    for i_o, (chr_o, _) in enumerate(orig):
        if chr_o in new_chrom_to_index.keys():
            remap_indexes[i_o] = new_chrom_to_index[chr_o]
    remap_indexes[None] = None
    return remap_indexes
105877
def _save_until_eos(ids, skip=False):
  """"""
  ids = ids.flatten()
  if skip:
    return ids
  try:
    index = list(ids).index(text_encoder.EOS_ID)
    return ids[0:index]
  except ValueError:
    # No EOS_ID: return the array as-is.
    return ids
273379
def getInstIdFromIndices(self, *indices):
        """"""
        try:
            return self._idxToIdCache[indices]
        except TypeError:
            cacheable = False
        except KeyError:
            cacheable = True
        idx = 0
        instId = ()
        parentIndices = []
        for impliedFlag, modName, symName in self._indexNames:
            if idx >= len(indices):
                break
            mibObj, = mibBuilder.importSymbols(modName, symName)
            syntax = mibObj.syntax.clone(indices[idx])
            instId += self.valueToOid(syntax, impliedFlag, parentIndices)
            parentIndices.append(syntax)
            idx += 1
        if cacheable:
            self._idxToIdCache[indices] = instId
        return instId
1184569
private void indexArrayStore(int e, int i)
    {
        if (valueIndexStore.length < e)
        {
            int oldLength = valueIndexStore.length;
            valueIndexStore = Arrays.copyOf(valueIndexStore, e + 2);
            Arrays.fill(valueIndexStore, oldLength, valueIndexStore.length, -1);
        }
        valueIndexStore[e] = i;
    }
428004
private void buildIndex(Collection<?> coll) {
        certSubjects = new HashMap<X500Principal, Object>();
        crlIssuers = new HashMap<X500Principal, Object>();
        otherCertificates = null;
        otherCRLs = null;
        for (Object obj : coll) {
            if (obj instanceof X509Certificate) {
                indexCertificate((X509Certificate)obj);
            } else if (obj instanceof X509CRL) {
                indexCRL((X509CRL)obj);
            } else if (obj instanceof Certificate) {
                if (otherCertificates == null) {
                    otherCertificates = new HashSet<Certificate>();
                }
                otherCertificates.add((Certificate)obj);
            } else if (obj instanceof CRL) {
                if (otherCRLs == null) {
                    otherCRLs = new HashSet<CRL>();
                }
                otherCRLs.add((CRL)obj);
            } else {
                // ignore
            }
        }
        if (otherCertificates == null) {
            otherCertificates = Collections.<Certificate>emptySet();
        }
        if (otherCRLs == null) {
            otherCRLs = Collections.<CRL>emptySet();
        }
    }
228280
protected function prepareIndex($index)
    {
        foreach ($index as &$value) {
            // Convert ascending
            $value = $value === 'asc' ? 1 : $value;

            // Convert descending
            $value = $value === 'desc' ? -1 : $value;

            // Convert geo to 2d
            $value = $value === 'geo' ? '2d' : $value;
        }

        return $index;
    }
1371761
def build_index(self, idx_name, _type='default'):
        ""
        indexes = {}
        has_non_string_values = False
        for key, item in self.data.items():
            if idx_name in item:
                value = item[idx_name]
                # A non-string index value switches it into a lazy one.
                if not isinstance(value, six.string_types):
                    has_non_string_values = True
                if value not in indexes:
                    indexes[value] = set([])
                indexes[value].add(key)
        self.indexes[idx_name] = indexes
        if self._meta.lazy_indexes or has_non_string_values:
            # Every index is lazy
            _type = 'lazy'
        self.index_defs[idx_name] = {'type': _type}
12622
public int moveToIndex(int index)
    {
        int index2 = index;
        int iErrorCode = DBConstants.NORMAL_RETURN;
        if (m_bIncludeBlankOption)
        {
            if (index == 0)
                iErrorCode = DBConstants.ERROR_RETURN;
            index2--; // Offset by one
        }
        if (index == -1)
            iErrorCode = DBConstants.ERROR_RETURN;
        if (iErrorCode == DBConstants.NORMAL_RETURN)
        {
            if (index2 != -1)
            {
                try
                {
                    Record record = (Record)m_gridTable.get(index2);    //?, DONT_DISPLAY);   // DON'T Display, or you will be caught in a loop
                    if (record == null)
                        iErrorCode = DBConstants.END_OF_FILE;
                }
                catch( DBException e )
                {
                    iErrorCode = e.getErrorCode();
                }
            }
            else
                iErrorCode = DBConstants.ERROR_RETURN;  // Do an addNew
        }
        else        // This is usually selecting index 0 or -1!
        {
            m_record.initRecord(DBConstants.DISPLAY);  // Clear the fields!
            iErrorCode = DBConstants.NORMAL_RETURN;   // Clear fields = record 0
        }
        return iErrorCode;
    }