:param sources: dictionaries with a key 'tectonicRegion'
        :returns: an ordered list of SourceGroup instances
19875
def collect(cls, sources):
        
        source_stats_dict = {}
        for src in sources:
            trt = src['tectonicRegion']
            if trt not in source_stats_dict:
                source_stats_dict[trt] = SourceGroup(trt)
            sg = source_stats_dict[trt]
            if not sg.sources:
                # we append just one source per SourceGroup, so that
                # the memory occupation is insignificant
                sg.sources.append(src)

        # return SourceGroups, ordered by TRT string
        return sorted(source_stats_dict.values())
1297691
def FindSourceFiles(self, node='.'):
        
        node = self.arg2nodes(node, self.fs.Entry)[0]

        sources = []
        def build_source(ss):
            for s in ss:
                if isinstance(s, SCons.Node.FS.Dir):
                    build_source(s.all_children())
                elif s.has_builder():
                    build_source(s.sources)
                elif isinstance(s.disambiguate(), SCons.Node.FS.File):
                    sources.append(s)
        build_source(node.all_children())

        def final_source(node):
            while (node != node.srcnode()):
              node = node.srcnode()
            return node
        sources = list(map( final_source, sources ));
        # remove duplicates
        return list(set(sources))
226252
def get_sources(self, kind='all'):
        
        assert kind in ('all', 'indep', 'mutex'), kind
        sources = []
        for sm in self.source_models:
            for src_group in sm.src_groups:
                if kind in ('all', src_group.src_interdep):
                    for src in src_group:
                        if sm.samples > 1:
                            src.samples = sm.samples
                        sources.append(src)
        return sources
1125955
def get_all_sources(self):
        
        if self.__all_sources is None:
            self.__all_sources = OrderedDict()
            self.walk(self.__add_one)
        return self.__all_sources
301917
def get_groups(self):
        
        res = self._make_ocs_request(
            'GET',
            self.OCS_SERVICE_CLOUD,
            'groups'
        )

        if res.status_code == 200:
            tree = ET.fromstring(res.content)
            groups = [x.text for x in tree.findall('data/groups/element')]

            return groups

        raise HTTPResponseError(res)
45857
def extract_source_geom(dstore, srcidxs):
    
    for i in srcidxs.split(','):
        rec = dstore['source_info'][int(i)]
        geom = dstore['source_geom'][rec['gidx1']:rec['gidx2']]
        yield rec['source_id'], geom
834973
def obs_groups(self):
        
        og = list(self.observation_data.groupby("obgnme").groups.keys())
        #og = list(map(pst_utils.SFMT, og))
        return og
830360
def _calculate_isortable_python_sources(self, targets):
    """"""
    sources = set()
    for target in targets:
      sources.update(
        source for source in target.sources_relative_to_buildroot()
        if os.path.splitext(source)[1] == self._PYTHON_SOURCE_EXTENSION
      )
    return list(sources)
28004
def groups(self):
        
        if len(self.groupings) == 1:
            return self.groupings[0].groups
        else:
            to_groupby = lzip(*(ping.grouper for ping in self.groupings))
            to_groupby = Index(to_groupby)
            return self.axis.groupby(to_groupby)
386874
def update_source_model(sm_node, fname):
    
    i = 0
    for group in sm_node:
        if 'srcs_weights' in group.attrib:
            raise InvalidFile('srcs_weights must be removed in %s' % fname)
        if not group.tag.endswith('sourceGroup'):
            raise InvalidFile('wrong NRML, got %s instead of '
                              'sourceGroup in %s' % (group.tag, fname))
        psrcs = []
        others = []
        for src in group:
            try:
                del src.attrib['tectonicRegion']  # make the trt implicit
            except KeyError:
                pass  # already missing
            if src.tag.endswith('pointSource'):
                psrcs.append(src)
            else:
                others.append(src)
        others.sort(key=lambda src: (src.tag, src['id']))
        i, sources = _pointsources2multipoints(psrcs, i)
        group.nodes = sources + others
823753
def get_source_model(self, src_group_id):
        
        for smodel in self.source_models:
            for src_group in smodel.src_groups:
                if src_group.id == src_group_id:
                    return smodel
759412
def source_model_info(nodes):
    
    c = collections.Counter()
    for node in nodes:
        for src_group in node:
            trt = src_group['tectonicRegion']
            for src in src_group:
                src_class = src.tag.split('}')[1]
                c[trt, src_class] += 1
    trts, classes = zip(*c)
    trts = sorted(set(trts))
    classes = sorted(set(classes))
    dtlist = [('TRT', (bytes, 30))] + [(name, int) for name in classes]
    out = numpy.zeros(len(trts) + 1, dtlist)  # +1 for the totals
    for i, trt in enumerate(trts):
        out[i]['TRT'] = trt
        for src_class in classes:
            out[i][src_class] = c[trt, src_class]
    out[-1]['TRT'] = 'Total'
    for name in out.dtype.names[1:]:
        out[-1][name] = out[name][:-1].sum()
    return rst_table(out)
317461
def from_sources_field(sources, spec_path):
    
    if sources is None:
      return Files(spec_path=spec_path)
    elif isinstance(sources, BaseGlobs):
      return sources
    elif isinstance(sources, string_types):
      return Files(sources, spec_path=spec_path)
    elif isinstance(sources, (MutableSet, MutableSequence, tuple)) and \
         all(isinstance(s, string_types) for s in sources):
      return Files(*sources, spec_path=spec_path)
    else:
      raise ValueError('Expected either a glob or list of literal sources: got: {}'.format(sources))
1160471
def list_event_sources(self):
        
        # Server does not do pagination on listings of this resource.
        # Return an iterator anyway for similarity with other API methods
        path = '/archive/{}/events/sources'.format(self._instance)
        response = self._client.get_proto(path=path)
        message = archive_pb2.EventSourceInfo()
        message.ParseFromString(response.content)
        sources = getattr(message, 'source')
        return iter(sources)
547138
def source(self):
        
        if len(self.sources) == 0:
            raise ValueError("No source associated with %s" % self.__class__.__name__)
        elif len(self.sources) > 1:
            raise ValueError("Multiple sources for %s" % self.__class__.__name__)
        return list(self.sources)[0]
1265425
def source_lookup(request):
    
    source = request.GET['source']
    source_slug = slugify(source.strip())
    source_candidates = Dataset.objects.values('source').filter(
        source_slug__startswith=source_slug
    )
    sources = json.dumps([cand['source'] for cand in source_candidates])

    return HttpResponse(sources, content_type='application/json')
242311
def get_skeleton(self):
        
        src_groups = []
        for grp in self.src_groups:
            sg = copy.copy(grp)
            sg.sources = []
            src_groups.append(sg)
        return self.__class__(self.names, self.weight, self.path, src_groups,
                              self.num_gsim_paths, self.ordinal, self.samples)