Test whether a source shows spectral curvature by comparing
        the likelihood ratio of PowerLaw and LogParabola spectral
        models.

        Parameters
        ----------
        name : str
            Source name.
15676
def curvature(self, name, **kwargs):
        

        name = self.roi.get_source_by_name(name).name

        saved_state = LikelihoodState(self.like)
        source = self.components[0].like.logLike.getSource(str(name))

        old_spectrum = source.spectrum()
        old_pars = copy.deepcopy(self.roi[name].spectral_pars)
        old_type = self.roi[name]['SpectrumType']

        if old_type != 'PowerLaw':

            dnde = self.like[name].spectrum()(pyLike.dArg(1000.))
            value, scale = utils.scale_parameter(dnde)
            pars0 = {
                'Prefactor':
                    {'value': value, 'scale': scale,
                        'min': 1E-5, 'max': 1000., 'free': True},
                'Index':
                    {'value': 2.0, 'scale': -1.0, 'min': 0.0,
                        'max': 5.0, 'free': False},
                'Scale':
                    {'value': 1E3, 'scale': 1.0, 'min': 1.,
                        'max': 1E6, 'free': False},
            }
            self.set_source_spectrum(str(name), 'PowerLaw',
                                     spectrum_pars=pars0,
                                     update_source=False)

        self.free_source(name, loglevel=logging.DEBUG)
        fit_pl = self._fit(loglevel=logging.DEBUG)

        prefactor = self._get_param(name, 'Prefactor')
        index = self._get_param(name, 'Index')
        scale = self._get_param(name, 'Scale')

        pars1 = {
            'norm': copy.deepcopy(prefactor),
            'alpha': copy.deepcopy(index),
            'Eb': copy.deepcopy(scale),
        }
        pars1['alpha']['scale'] *= -1
        pars1['alpha']['min'] = -5.0
        pars1['alpha']['max'] = 5.0

        self.set_source_spectrum(str(name), 'LogParabola',
                                 spectrum_pars=pars1,
                                 update_source=False)

        self.free_source(name, loglevel=logging.DEBUG)
        fit_lp = self._fit(loglevel=logging.DEBUG)

        self.set_source_spectrum(str(name), old_type,
                                 spectrum_pars=old_pars,
                                 update_source=False)

        pars2 = {
            'Prefactor': copy.deepcopy(prefactor),
            'Index1': copy.deepcopy(index),
            'Cutoff': {'value': 1000.0, 'scale': 1E3,
                       'min': 10.0, 'max': 1E4, 'free': True},
            'Index2': {'value': 1.0, 'scale': 1.0,
                       'min': 1.0, 'max': 1.0, 'free': False},
            'Scale': copy.deepcopy(scale)
        }

        self.set_source_spectrum(str(name), 'PLSuperExpCutoff',
                                 spectrum_pars=pars2,
                                 update_source=False)

        self.free_source(name, loglevel=logging.DEBUG)
        fit_ple = self._fit(loglevel=logging.DEBUG)

        # Revert to initial spectral model
        self.set_source_spectrum(str(name), old_type,
                                 spectrum_pars=old_pars,
                                 update_source=False)
        saved_state.restore()

        lp_ts_curv = 2.0 * (fit_lp['loglike'] - fit_pl['loglike'])
        ple_ts_curv = 2.0 * (fit_ple['loglike'] - fit_pl['loglike'])
        o = MutableNamedTuple(ts_curv=lp_ts_curv,
                              lp_ts_curv=lp_ts_curv,
                              ple_ts_curv=ple_ts_curv,
                              loglike_pl=fit_pl['loglike'],
                              loglike_lp=fit_lp['loglike'],
                              loglike_ple=fit_ple['loglike'])

        self.logger.info('LogLike_PL: %12.3f LogLike_LP: %12.3f LogLike_PLE: %12.3f',
                         o.loglike_pl, o.loglike_lp, o.loglike_ple)
        self.logger.info('TS_curv:        %.3f (LP)', o.lp_ts_curv)
        self.logger.info('TS_curv:        %.3f (PLE)', o.ple_ts_curv)
        return o
1112542
def has_name_version(self, name: str, version: str) -> bool:
        """"""
        return self.session.query(exists().where(and_(Network.name == name, Network.version == version))).scalar()
959410
def _name_exists(self, name):
        
        for i in range(self.count()):
            if self.tabText(i) == name:
                return True
        return False
1361888
def lookup(cls, name):
        
        try:
            field = cls.FIELDS[name]
        except KeyError:
            # Is it a custom attribute?
            field = TorrentProxy.add_manifold_attribute(name)

        return {"matcher": field._matcher} if field else None
997511
def spectral_template(self, **kwargs):
        
        kwargs_copy = self.base_dict.copy()
        kwargs_copy.update(**kwargs)
        localpath = NameFactory.spectral_template_format.format(**kwargs_copy)
        if kwargs.get('fullpath', False):
            return self.fullpath(localpath=localpath)
        return localpath
604706
def real_name?(str)
      parsed = @parser.parse(str)[:scientificName]
      return false unless parsed[:parsed]
      epithets = parsed[:canonical].split(" ")[1..-1]
      return false if epithets.nil? || epithets.empty?
      epithets.each do |e|
        return false if @black_sp[e]
      end
      true
    end
851506
def nametonum(name):
    
    code = colorcodes.get(name)
    if code is None:
        raise ValueError("%s is not a valid color name." % name)
    else:
        return code
360739
def has_index(self, name):
        
        name = self._normalize_identifier(name)

        return name in self._indexes
243787
private String determineQualifiedName(String name, CompilationUnit from) {
        if (from != null) {
            // Determine qualified name as being relative to "from"

            String fromName = from.getName();
            int index = fromName.lastIndexOf('.');
            if (index >= 0) {
                String qual = fromName.substring(0, index + 1) + name;
                if (sourceExists(qual)) {
                    return qual;
                }
            }
        }

        if (sourceExists(name)) {
            return name;
        }

        return null;
    }
1331178
def source_filter(method_name, *args, **kwargs):
    

    def source_filter(value, context, **_params):
        method = getattr(context["model"].source, method_name)
        return _filter(method, value, args, kwargs)

    return source_filter
175659
def with_name(self, name):
        """"""
        if not self.name:
            raise ValueError("%r has an empty name" % (self,))
        return self._from_parsed_parts(self._drv, self._root,
                                       self._parts[:-1] + [name])
213471
def derive_resource_name(name):
    """"""
    if name.startswith("Anon"):
        name = name[4:]
    if name.endswith("Handler"):
        name = name[:-7]
    if name == "Maas":
        name = "MAAS"
    return name
110693
def name_matches(self, name: str) -> bool:
        
        return bool(self.regex.match(name))
71772
def getParameterByName(self, name):
        """"""
        result = None
        for parameter in self.getParameters():
            nameParam = parameter.getName()
            if nameParam == name:
                result = parameter
                break
        return result
433543
def guessFormat(self, name):
        
        name = name.lower()
        generator = self.generator
        if re.findall(r'^is[_A-Z]', name): return lambda x:generator.boolean()
        if re.findall(r'(_a|A)t$', name): return lambda x:generator.dateTime()

        if name in ('first_name','firstname'): return lambda x: generator.firstName()
        if name in ('last_name','lastname'): return lambda x: generator.lastName()

        if name in ('username','login','nickname'): return lambda x:generator.userName()
        if name in ('email','email_address'): return lambda x:generator.email()
        if name in ('phone_number','phonenumber','phone'): return lambda x:generator.phoneNumber()
        if name == 'address' : return lambda x:generator.address()
        if name == 'city' : return lambda x: generator.city()
        if name == 'streetaddress' : return lambda x: generator.streetaddress()
        if name in ('postcode','zipcode'): return lambda x: generator.postcode()
        if name == 'state' : return lambda x: generator.state()
        if name == 'country' : return lambda x: generator.country()
        if name == 'title' : return lambda x: generator.sentence()
        if name in ('body','summary', 'description'): return lambda x: generator.text()
580442
def hasProp(self, name):
        
        ret = libxml2mod.xmlHasProp(self._o, name)
        if ret is None:return None
        __tmp = xmlAttr(_obj=ret)
        return __tmp
1169873
def named_eq_relations(self, name, neg=False):
        '''
        '''
        if self.eqLinks and not neg:

            if isinstance(name, six.string_types):
                return filter(lambda x: x.relation.name == name,
                              self.eqLinks)

            elif isinstance(name, list):
                return filter(lambda x: x.relation.name in name,
                              self.eqLinks)
            else:
                return None #should rise error

        elif self.eqLinks and neg:

            if isinstance(name, six.string_types):
                return filter(lambda x: x.relation.name != name,
                              self.eqLinks)

            elif isinstance(name, list):
                return filter(lambda x: x.relation.name not in name,
                              self.eqLinks)
            else:
                return None #should rise error
        else:
            return None