Get 2-D list of sections and hdrgos sets actually used in grouping.
165671
def get_sections_2d(self):
        """"""
        sections_hdrgos_act = []
        hdrgos_act_all = self.get_hdrgos()  # Header GOs actually used to group
        hdrgos_act_secs = set()
        if self.hdrobj.sections:
            for section_name, hdrgos_all_lst in self.hdrobj.sections:
                # print("GGGGGGGGGGGGGGGGG {N:3} {NAME}".format(N=len(hdrgos_all_lst), NAME=section_name))
                hdrgos_all_set = set(hdrgos_all_lst)
                hdrgos_act_set = hdrgos_all_set.intersection(hdrgos_act_all)
                if hdrgos_act_set:
                    hdrgos_act_secs |= hdrgos_act_set
                    # Use original order of header GOs found in sections
                    hdrgos_act_lst = []
                    hdrgos_act_ctr = cx.Counter()
                    for hdrgo_p in hdrgos_all_lst: # Header GO that may or may not be used.
                        if hdrgo_p in hdrgos_act_set and hdrgos_act_ctr[hdrgo_p] == 0:
                            hdrgos_act_lst.append(hdrgo_p)
                        hdrgos_act_ctr[hdrgo_p] += 1
                    sections_hdrgos_act.append((section_name, hdrgos_act_lst))
            # print(">>>>>>>>>>>>>>> hdrgos_act_all {N:3}".format(N=len(hdrgos_act_all)))
            # print(">>>>>>>>>>>>>>> hdrgos_act_secs {N:3}".format(N=len(hdrgos_act_secs)))
            hdrgos_act_rem = hdrgos_act_all.difference(hdrgos_act_secs)
            if hdrgos_act_rem:
                # print("RRRRRRRRRRR {N:3}".format(N=len(hdrgos_act_rem)))
                sections_hdrgos_act.append((self.hdrobj.secdflt, hdrgos_act_rem))
        else:
            sections_hdrgos_act.append((self.hdrobj.secdflt, hdrgos_act_all))
        return sections_hdrgos_act
298797
def _get_groups(self, data):
        
        groups = []
        for attribute in SOURCE_KEYS:
            for k, v in data[attribute].items():
                if k == None:
                    k = 'Sources'
                if k not in groups:
                    groups.append(k)
        for k, v in data['include_files'].items():
            if k == None:
                k = 'Includes'
            if k not in groups:
                groups.append(k)
        return groups
38223
def list_sections(self):
        """"""
        if not os.path.exists(self._full_base):
            return []
        return [
            name for name in os.listdir(self._full_base)
            if os.path.isdir(os.path.join(self._full_base, name))
        ]
263100
private Set<String> getGroups(DirContext context, String callerDn) {
        Set<String> groups = null;
        String groupSearchBase = idStoreDefinition.getGroupSearchBase();
        String groupSearchFilter = idStoreDefinition.getGroupSearchFilter();
        if (groupSearchBase.isEmpty() || groupSearchFilter.isEmpty()) {
            groups = getGroupsByMembership(context, callerDn);
        } else {
            groups = getGroupsByMember(context, callerDn, groupSearchBase, groupSearchFilter);
        }
        return groups;
    }
1262788
def select_groups(adata, groups='all', key='louvain'):
    
    strings_to_categoricals(adata)
    if isinstance(groups, list) and isinstance(groups[0], int): groups = [str(n) for n in groups]
    categories = adata.obs[key].cat.categories
    groups_masks = np.array([categories[i] == adata.obs[key].values for i, name in enumerate(categories)])
    if groups == 'all':
        groups = categories.values
    else:
        groups_ids = [np.where(categories.values == name)[0][0] for name in groups]
        groups_masks = groups_masks[groups_ids]
        groups = categories[groups_ids].values
    return groups, groups_masks
712621
def group_by_source(self):
        """"""
        from collections import defaultdict
        docs = defaultdict(list)

        for k, v in self.items():
            if 'source' in v:
                docs[v.source].append(dict(v.items()))

        return docs
188449
def get_desc2nts_fnc(self, hdrgo_prt=True, section_prt=None,
                         top_n=None, use_sections=True):
        """"""
        # RETURN: flat list of namedtuples
        nts_flat = self.get_nts_flat(hdrgo_prt, use_sections)
        if nts_flat:
            flds = nts_flat[0]._fields
            if not use_sections:
                return {'sortobj':self, 'flat' : nts_flat, 'hdrgo_prt':hdrgo_prt, 'flds':flds,
                        'num_items':len(nts_flat), 'num_sections':1}
            else:
                return {'sortobj':self,
                        'sections' : [(self.grprobj.hdrobj.secdflt, nts_flat)],
                        'hdrgo_prt':hdrgo_prt,
                        'flds':flds,
                        'num_items':len(nts_flat), 'num_sections':1}
        # print('FFFF Sorter:get_desc2nts_fnc: nts_flat is None')
        # RETURN: 2-D list [(section_name0, namedtuples0), (section_name1, namedtuples1), ...
        #     kws: top_n hdrgo_prt section_sortby
        # Over-ride hdrgo_prt depending on top_n value
        assert top_n is not True and top_n is not False, \
            "top_n({T}) MUST BE None OR AN int".format(T=top_n)
        assert self.sectobj is not None, "SECTIONS OBJECT DOES NOT EXIST"
        sec_sb = self.sectobj.section_sortby
        # Override hdrgo_prt, if sorting by sections or returning a subset of GO IDs in section
        hdrgo_prt_curr = hdrgo_prt is True
        if sec_sb is True or (sec_sb is not False and sec_sb is not None) or top_n is not None:
            hdrgo_prt_curr = False
        # print('GGGG Sorter:get_desc2nts_fnc: hdrgo_prt_curr({}) sec_sb({}) top_n({})'.format(
        #     hdrgo_prt_curr, sec_sb, top_n))
        nts_section = self.sectobj.get_sorted_nts_keep_section(hdrgo_prt_curr)
        # print('HHHH Sorter:get_desc2nts_fnc: nts_section')
        # Take top_n in each section, if requested
        if top_n is not None:
            nts_section = [(s, nts[:top_n]) for s, nts in nts_section]
            if section_prt is None:
                nts_flat = self.get_sections_flattened(nts_section)
                flds = nts_flat[0]._fields if nts_flat else []
                return {'sortobj':self, 'flat' : nts_flat, 'hdrgo_prt':hdrgo_prt_curr, 'flds':flds,
                        'num_items':len(nts_flat), 'num_sections':1}
        # Send flat list of sections nts back, as requested
        if section_prt is False:
            nts_flat = self.get_sections_flattened(nts_section)
            flds = nts_flat[0]._fields if nts_flat else []
            return {'sortobj':self, 'flat' : nts_flat, 'hdrgo_prt':hdrgo_prt_curr, 'flds':flds,
                    'num_items':len(nts_flat),
                    'num_sections':len(nts_section)}
        # Send 2-D sections nts back
        # print('IIII Sorter:get_desc2nts_fnc: nts_section')
        flds = nts_section[0][1][0]._fields if nts_section else []
        return {'sortobj':self, 'sections' : nts_section, 'hdrgo_prt':hdrgo_prt_curr, 'flds':flds,
                'num_items':sum(len(nts) for _, nts in nts_section),
                'num_sections':len(nts_section)}
80029
def get_hdrgos_g_usrgos(self, usrgos):
        """"""
        hdrgos_for_usrgos = set()
        hdrgos_all = self.get_hdrgos()
        usrgo2hdrgo = self.get_usrgo2hdrgo()
        for usrgo in usrgos:
            if usrgo in hdrgos_all:
                hdrgos_for_usrgos.add(usrgo)
                continue
            hdrgo_cur = usrgo2hdrgo.get(usrgo, None)
            if hdrgo_cur is not None:
                hdrgos_for_usrgos.add(hdrgo_cur)
        return hdrgos_for_usrgos
951011
def chunkWidgets(self, group):
        '''  '''
        ui_groups = []
        subgroup = []
        for index, item in enumerate(group['items']):
            if getin(item, ['options', 'full_width'], False):
                ui_groups.append(subgroup)
                ui_groups.append([item])
                subgroup = []
            else:
                subgroup.append(item)
            if len(subgroup) == getin(group, ['options', 'columns'], 2) \
                    or item == group['items'][-1]:
                ui_groups.append(subgroup)
                subgroup = []
        return ui_groups
776761
def get_nts_sections(self, sections, sortby=None):
        """"""
        goids = self.get_goids_sections(sections)
        gosubdag = GoSubDag(goids, self.go2obj)
        return [(sec, gosubdag.get_nts(gos, sortby)) for sec, gos in sections]
1362442
def prior_groups(self):
        
        og = list(self.prior_information.groupby("obgnme").groups.keys())
        #og = list(map(pst_utils.SFMT, og))
        return og
819981
def get_sorted_nts_keep_section(self, hdrgo_prt):
        """"""
        section_nts = []
        # print("SSSS SorterNts:get_sorted_nts_keep_section(hdrgo_prt={})".format(hdrgo_prt))
        hdrgos_actual = self.sortgos.grprobj.get_hdrgos()
        hdrgos_secs = set()
        hdrgo_sort = False if self.section_sortby is False else True
        secname_dflt = self.sortgos.grprobj.hdrobj.secdflt
        for section_name, section_hdrgos_all in self.sections:
            #section_hdrgos_act = set(section_hdrgos_all).intersection(hdrgos_actual)
            section_hdrgos_act = [h for h in section_hdrgos_all if h in hdrgos_actual]
            hdrgos_secs |= set(section_hdrgos_act)
            nts_section = self.sortgos.get_nts_sorted(hdrgo_prt, section_hdrgos_act, hdrgo_sort)
            if nts_section:
                nts_section = self._get_sorted_section(nts_section)
                section_nts.append((section_name, nts_section))
        remaining_hdrgos = hdrgos_actual.difference(hdrgos_secs)
        # Add GO group headers not yet used under new section, Misc.
        if remaining_hdrgos:
            nts_section = self.sortgos.get_nts_sorted(hdrgo_prt, remaining_hdrgos, hdrgo_sort)
            if nts_section:
                nts_section = self._get_sorted_section(nts_section)
                section_nts.append((secname_dflt, nts_section))
        return section_nts
334757
def wr_txt_grouping_gos(self):
        """"""
        prt_goids = self.grprobj.gosubdag.prt_goids
        for hdrgo, usrgos in self.grprobj.hdrgo2usrgos.items():
            keygos = usrgos.union([hdrgo])
            fout_txt = "{BASE}.txt".format(BASE=self.grprobj.get_fout_base(hdrgo))
            with open(fout_txt, 'w') as prt:
                prt_goids(keygos, prt=prt)
                sys.stdout.write("  {N:5,} GO IDs WROTE: {TXT}\n".format(
                    N=len(keygos), TXT=fout_txt))
715455
def get_groups(self, table_name):
        
        df = self.dm[table_name]
        return list(df['group'].unique())
989786
function getAllEntries(groups) {
    return groups.reduce(function(current, group) {
        const theseEntries = group.getEntries();
        const subEntries = getAllEntries(group.getGroups());
        if (theseEntries.length > 0) {
            current = current.concat(theseEntries);
        }
        if (subEntries.length > 0) {
            current = current.concat(subEntries);
        }
        return current;
    }, []);
}
1151468
def groups(self):
        
        if not self._groups:
            self._groups = ComponentGroups(self.api_client)
        return self._groups
393649
def get_fields(desc2nts):
        """"""
        if 'flat' in desc2nts:
            nts_flat = desc2nts.get('flat')
            if nts_flat:
                return nts_flat[0]._fields
        if 'sections' in desc2nts:
            nts_sections = desc2nts.get('sections')
            if nts_sections:
                return nts_sections[0][1][0]._fields