:returns: a new CompositeSourceModel with one group per source
778671
def grp_by_src(self):
        
        smodels = []
        grp_id = 0
        for sm in self.source_models:
            src_groups = []
            smodel = sm.__class__(sm.names, sm.weight, sm.path, src_groups,
                                  sm.num_gsim_paths, sm.ordinal, sm.samples)
            for sg in sm.src_groups:
                for src in sg.sources:
                    src.src_group_id = grp_id
                    src_groups.append(
                        sourceconverter.SourceGroup(
                            sg.trt, [src], name=src.source_id, id=grp_id))
                    grp_id += 1
            smodels.append(smodel)
        return self.__class__(self.gsim_lt, self.source_model_lt, smodels,
                              self.optimize_same_id)
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
27281
def clone(self, **kwargs):
        '''
        
        '''
        child = ChildContextDict(parent=self, threadsafe=self._threadsafe, overrides=kwargs)
        return child
234739
def copy(self):
        # type: () -> Requirement
        
        return Requirement(
            self.specification,
            self.aggregate,
            self.optional,
            self.__original_filter,
            self.immediate_rebind,
        )
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())
16256
def _create_one(self, ctx):
        
        assert isinstance(ctx, ResourceQueryContext)

        fields = dict_pick(ctx.data, self._model_columns)
        model = self.model_cls(**fields)
        return model
106783
public GroupResources groupResources() {
        if (groups.get() == null) {
            groups.compareAndSet(null, new GroupResourcesImpl(this));
        }
        return groups.get();
    }
1218764
def _ExpandArtifactGroupSource(self, source, requested):
    """"""
    artifact_list = []
    if "names" in source.attributes:
      artifact_list = source.attributes["names"]
    for artifact_name in artifact_list:
      if artifact_name in self.processed_artifacts:
        continue
      artifact_obj = artifact_registry.REGISTRY.GetArtifact(artifact_name)
      for expanded_artifact in self.Expand(artifact_obj, requested):
        yield expanded_artifact
738996
def createGroupResponse(self, group, vendorSpecific=None):
        
        mmp_dict = {'group': ('group.xml', group.toxml('utf-8'))}
        return self.POST('groups', fields=mmp_dict, headers=vendorSpecific)
739967
def get_sm_by_grp(self):
        
        return {grp.id: sm.ordinal for sm in self.source_models
                for grp in sm.src_groups}
1057367
def create_groups(self, container):
        
        content = self._serialize.body(container, 'object')
        response = self._send(http_method='POST',
                              location_id='5966283b-4196-4d57-9211-1b68f41ec1c2',
                              version='5.0',
                              content=content)
        return self._deserialize('[Identity]', self._unwrap_collection(response))
1081862
def create_group(self, **kwargs):
        
        response = self.__requester.request(
            'POST',
            'groups',
            _kwargs=combine_kwargs(**kwargs)
        )
        return Group(self.__requester, response.json())
466910
private DataMediaSource doToModel(DataMediaSourceDO dataMediaSourceDo) {

        DataMediaSource dataMediaSource = new DbMediaSource();
        try {
            if (dataMediaSourceDo.getType().isMysql() || dataMediaSourceDo.getType().isOracle()) {
                dataMediaSource = JsonUtils.unmarshalFromString(dataMediaSourceDo.getProperties(), DbMediaSource.class);
            } else if (dataMediaSourceDo.getType().isNapoli() || dataMediaSourceDo.getType().isMq()) {
                dataMediaSource = JsonUtils.unmarshalFromString(dataMediaSourceDo.getProperties(), MqMediaSource.class);
            }

            dataMediaSource.setId(dataMediaSourceDo.getId());
            dataMediaSource.setGmtCreate(dataMediaSourceDo.getGmtCreate());
            dataMediaSource.setGmtModified(dataMediaSourceDo.getGmtModified());
        } catch (Exception e) {
            logger.error("ERROR ## change the dataMediaSource Do to Model has an exception");
            throw new ManagerException(e);
        }

        return dataMediaSource;
    }
825697
def new(self, layer_groups:Collection[nn.Module], split_no_wd:bool=True):
        ""
        opt_func = getattr(self, 'opt_func', self.opt.__class__)
        res = self.create(opt_func, self.lr, layer_groups, wd=self.wd, true_wd=self.true_wd, bn_wd=self.bn_wd)
        res.mom,res.beta = self.mom,self.beta
        return res
1025260
def get_grouped_translations(instances, **kwargs):
    
    grouped_translations = collections.defaultdict(list)

    if not instances:
        return grouped_translations

    if not isinstance(instances, collections.Iterable):
        instances = [instances]

    if isinstance(instances, QuerySet):
        model = instances.model
    else:
        model = instances[0]._meta.model

    instances_ids = []

    for instance in instances:
        instances_ids.append(instance.pk)

        if instance._meta.model != model:
            raise Exception(
                "You cannot use different model instances, only one authorized."
            )

    from .models import Translation
    from .mixins import ModelMixin

    decider = model._meta.linguist.get("decider", Translation)
    identifier = model._meta.linguist.get("identifier", None)
    chunks_length = kwargs.get("chunks_length", None)
    populate_missing = kwargs.get("populate_missing", True)

    if identifier is None:
        raise Exception('You must define Linguist "identifier" meta option')

    lookup = dict(identifier=identifier)
    for kwarg in ("field_names", "languages"):
        value = kwargs.get(kwarg, None)
        if value is not None:
            if not isinstance(value, (list, tuple)):
                value = [value]
            lookup["%s__in" % kwarg[:-1]] = value

    if chunks_length is not None:
        translations_qs = []
        for ids in utils.chunks(instances_ids, chunks_length):
            ids_lookup = copy.copy(lookup)
            ids_lookup["object_id__in"] = ids
            translations_qs.append(decider.objects.filter(**ids_lookup))
        translations = itertools.chain.from_iterable(translations_qs)
    else:
        lookup["object_id__in"] = instances_ids
        translations = decider.objects.filter(**lookup)

    for translation in translations:
        grouped_translations[translation.object_id].append(translation)

    return grouped_translations
900938
function groupsFactory() {
  let list = []

  const getGroupsByRoot = function(root) {
    for (let i = 0; i < list.length; i++) {
      let groups = list[i]
      if (groups.rootEl === root) {
        return groups
      }
    }
    return null
  }

  return {
    add: function(root, group) {
      let groups = getGroupsByRoot(root)
      if (!groups) {
        groups = new Groups(root, [])
        list.push(groups)
      }
      if (group) {
        group._list = groups
        group.resolve()

        groups.add(group)
      }
    },
    groups: function() {
      return list.length === 1 ? list[0] : list
    }
  }
}
440241
def layer_groups(ordering, length=2):
   
   group_orderings = defaultdict(list)
   for el in ordering:
      group_orderings[el[:length]].append(el)
   return group_orderings