Build and return a `fermipy.roi_model.ROIModel object from
        a list of fermipy.catalog.Catalog` objects
766013
def make_fermipy_roi_model_from_catalogs(cataloglist):
        
        data = dict(catalogs=cataloglist,
                    src_roiwidth=360.)
        return roi_model.ROIModel(data, skydir=SkyCoord(0.0, 0.0, unit='deg'))
517626
def model_from_list(l, header):
        """"""
        col = groups.sortableListe(PseudoAccesCategorie(n) for n in l)
        return MultiSelectModel(col, header)
1019781
def _pipeline_objects(pipeline_objects_from_pillars, pipeline_object_overrides):
    '''
    
    '''
    from_pillars = copy.deepcopy(__salt__['pillar.get'](pipeline_objects_from_pillars))
    from_pillars.update(pipeline_object_overrides)
    pipeline_objects = _standardize(_dict_to_list_ids(from_pillars))
    for pipeline_object in pipeline_objects:
        pipeline_object['fields'] = _properties_from_dict(pipeline_object['fields'])
    return pipeline_objects
1305992
def catalogFactory(name, **kwargs):
    
    fn = lambda member: inspect.isclass(member) and member.__module__==__name__
    catalogs = odict(inspect.getmembers(sys.modules[__name__], fn))

    if name not in list(catalogs.keys()):
        msg = "%s not found in catalogs:\n %s"%(name,list(kernels.keys()))
        logger.error(msg)
        msg = "Unrecognized catalog: %s"%name
        raise Exception(msg)

    return catalogs[name](**kwargs)
816010
def from_lists(cls, path:PathOrStr, fnames:FilePathList, labels:Collection[str], valid_pct:float=0.2,
                   item_cls:Callable=None, **kwargs):
        ""
        item_cls = ifnone(item_cls, ImageList)
        fname2label = {f:l for (f,l) in zip(fnames, labels)}
        src = (item_cls(fnames, path=path).split_by_rand_pct(valid_pct)
                                .label_from_func(lambda x:fname2label[x]))
        return cls.create_from_ll(src, **kwargs)
1130653
def list_objects(self):
        '''  '''
        for i in self._execute('select * from objects'):
            _id, code = i
            yield _id, code, self.deserialize(code)
396086
def _get_model_without_dependencies(self, models_dict):
        '''
        
        '''
        next_model = None
        if not models_dict:
            return next_model

        for model, dependencies in six.iteritems(models_dict):
            if dependencies == []:
                next_model = model
                break

        if next_model is None:
            raise ValueError('incomplete model definitions, models in dependency '
                             'list not defined: {0}'.format(models_dict))

        # remove the model from other depednencies before returning
        models_dict.pop(next_model)
        for model, dep_list in six.iteritems(models_dict):
            if next_model in dep_list:
                dep_list.remove(next_model)

        return next_model
182257
def items(self):
        
        temp = self.clone()
        return [(f, getattr(temp, f)) for f in iter(self)]
980011
def make_model_rois(self, components, name_factory):
        
        ret_dict = {}

        # Figure out which sources need to be split by components
        master_roi_source_info = {}
        sub_comp_sources = {}
        for comp_name, model_comp in self.model_components.items():
            comp_info = model_comp.info
            if comp_info.components is None:
                master_roi_source_info[comp_name] = model_comp
            else:
                sub_comp_sources[comp_name] = model_comp

        # Build the xml for the master
        master_roi = SourceFactory.make_roi(master_roi_source_info)
        master_xml_mdl = name_factory.master_srcmdl_xml(
            modelkey=self.model_name)
        print("Writing master ROI model to %s" % master_xml_mdl)
        master_roi.write_xml(master_xml_mdl)
        ret_dict['master'] = master_roi

        # Now deal with the components
        for comp in components:
            zcut = "zmax%i" % comp.zmax
            compkey = "%s_%s" % (zcut, comp.make_key(
                '{ebin_name}_{evtype_name}'))
            # name_keys = dict(zcut=zcut,
            #                 modelkey=self.model_name,
            #                 component=compkey)
            comp_roi_source_info = {}
            for comp_name, model_comp in sub_comp_sources.items():
                comp_info = model_comp.info
                if comp_info.selection_dependent:
                    key = comp.make_key('{ebin_name}_{evtype_name}')
                elif comp_info.moving:
                    key = zcut
                info_clone = comp_info.components[key].clone_and_merge_sub(key)
                comp_roi_source_info[comp_name] =\
                    ModelComponent(info=info_clone,
                                   spectrum=model_comp.spectrum)

            # Build the xml for the component
            comp_roi = SourceFactory.make_roi(comp_roi_source_info)
            comp_xml_mdl = name_factory.comp_srcmdl_xml(modelkey=self.model_name,
                                                        component=compkey)
            print("Writing component ROI model to %s" % comp_xml_mdl)
            comp_roi.write_xml(comp_xml_mdl)
            ret_dict[compkey] = comp_roi

        return ret_dict
1350472
def get_models(cls, index, as_class=False):
        '''
        
        '''
        try:
            return cls._index_to_model[index] if as_class else cls._idx_name_to_mdl_to_mdlidx[index].keys()
        except KeyError:
            raise KeyError('Could not find any index named {}. Is this index defined in BUNGIESEARCH["INDICES"]?'.format(index))
239212
def get_objects(self, force=None, last_update=None, flush=False):
        '''
        
        '''
        return self._run_object_import(force=force, last_update=last_update,
                                       flush=flush, full_history=False)
76736
def _to_torch(Z, dtype=None):
        """"""
        if isinstance(Z, list):
            return [Classifier._to_torch(z, dtype=dtype) for z in Z]
        else:
            return Classifier._to_torch(Z)
140431
def _modeldesc_from_dict(self, d):
        """"""
        lhs_termlist = [Term([LookupFactor(d['lhs_termlist'][0])])]
        rhs_termlist = []
        for name in d['rhs_termlist']:
            if name == '':
                rhs_termlist.append(Term([]))
            else:
                rhs_termlist.append(Term([LookupFactor(name)]))

        md = ModelDesc(lhs_termlist, rhs_termlist)
        return md
1239224
def get_app_model_classes(self):
        
        models = []
        for m in self.models:
            mod, cls = m.rsplit('.', 1)
            mod = import_module(mod)
            models.append(getattr(mod, cls))
        return models
868826
def get_objects_of_class(cls):
        
        return list(o for o in gc.get_objects() if isinstance(o, cls))
637545
def obj_classes_from_module(module):
    """"""
    for name in dir(module):
        if not name.startswith('_'):
            cls = getattr(module, name)
            if getattr(cls, 'classID', None):
                yield (name, cls)
1233994
def models_from_model(model, include_related=False, exclude=None):
    ''''''
    if exclude is None:
        exclude = set()
    if model and model not in exclude:
        exclude.add(model)
        if isinstance(model, ModelType) and not model._meta.abstract:
            yield model
            if include_related:
                exclude.add(model)
                for field in model._meta.fields:
                    if hasattr(field, 'relmodel'):
                        through = getattr(field, 'through', None)
                        for rmodel in (field.relmodel, field.model, through):
                            for m in models_from_model(
                                    rmodel, include_related=include_related,
                                    exclude=exclude):
                                yield m
                for manytomany in model._meta.manytomany:
                    related = getattr(model, manytomany)
                    for m in models_from_model(related.model,
                                               include_related=include_related,
                                               exclude=exclude):
                        yield m
        elif not isinstance(model, ModelType) and isclass(model):
            # This is a class which is not o ModelType
            yield model