当前位置: 首页>>代码示例>>Python>>正文


Python utils.NoNewAttributesAfterInit类代码示例

本文整理汇总了Python中sherpa.utils.NoNewAttributesAfterInit的典型用法代码示例。如果您正苦于以下问题:Python NoNewAttributesAfterInit类的具体用法?Python NoNewAttributesAfterInit怎么用?Python NoNewAttributesAfterInit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NoNewAttributesAfterInit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, pha):
        self.pha = pha
        arf, rmf = pha.get_response()
        if arf is None and rmf is None:
            raise DataErr('norsp', pha.name)

        NoNewAttributesAfterInit.__init__(self)
开发者ID:mirca,项目名称:sherpa,代码行数:7,代码来源:instrument.py

示例2: __setattr__

    def __setattr__(self, name, val):

        par = getattr(self, name.lower(), None)
        if (par is not None) and isinstance(par, Parameter):
            par.val = val
        else:
            NoNewAttributesAfterInit.__setattr__(self, name, val)
开发者ID:anetasie,项目名称:sherpa,代码行数:7,代码来源:logposterior.py

示例3: __init__

    def __init__(self, modelname, name, val, min=-hugeval, max=hugeval,
                 hard_min=-hugeval, hard_max=hugeval, units='',
                 frozen=False, alwaysfrozen=False, hidden=False, aliases=None):
        self.modelname = modelname
        self.name = name
        self.fullname = '%s.%s' % (modelname, name)

        self._hard_min = SherpaFloat(hard_min)
        self._hard_max = SherpaFloat(hard_max)
        self.units = units

        self._alwaysfrozen = bool(alwaysfrozen)
        if alwaysfrozen:
            self._frozen = True
        else:
            self._frozen = frozen

        self.hidden = hidden

        # Set validated attributes.  Access them via their properties so that
        # validation takes place.
        self.min = min
        self.max = max
        self.val = val
        self.default_min = min
        self.default_max = max
        self.default_val = val
        self.link = None
        self._guessed = False

        self.aliases = [a.lower() for a in aliases] if aliases is not None else []

        NoNewAttributesAfterInit.__init__(self)
开发者ID:DougBurke,项目名称:sherpa,代码行数:33,代码来源:parameter.py

示例4: __init__

 def __init__(self):
     self.priors = {}
     self._walker = Walk
     self._sampler = MetropolisMH
     self._sampler_opt = get_keyword_defaults(MetropolisMH.init)
     self.sample = None
     self.walk = lambda: None
     NoNewAttributesAfterInit.__init__(self)
开发者ID:DougBurke,项目名称:sherpa,代码行数:8,代码来源:__init__.py

示例5: __init__

 def __init__(self, ratios, stats, samples, lr, ppp, null, alt):
     self.ratios = numpy.asarray(ratios)
     self.stats = numpy.asarray(stats)
     self.samples = numpy.asarray(samples)
     self.lr = float(lr)
     self.ppp = float(ppp)
     self.null = float(null)
     self.alt = float(alt)
     NoNewAttributesAfterInit.__init__(self)
开发者ID:anetasie,项目名称:sherpa,代码行数:9,代码来源:simulate.py

示例6: __init__

 def __init__(self, name, type, crval, crpix, cdelt,
              crota=0.0, epoch=2000.0, equinox=2000.0):
     self.name = name
     self.type = type
     self.crval = numpy.asarray(crval, dtype=float)
     self.crpix = numpy.asarray(crpix, dtype=float)
     self.cdelt = numpy.asarray(cdelt, dtype=float)
     self.crota = crota
     self.epoch = epoch
     self.equinox = equinox
     NoNewAttributesAfterInit.__init__(self)
开发者ID:anetasie,项目名称:sherpa-old,代码行数:11,代码来源:wcs.py

示例7: __setattr__

    def __setattr__(self, name, val):
        rmf = None
        try:
            rmf = RMF1D.__getattribute__(self, '_rmf')
        except:
            pass

        if rmf is not None and hasattr(rmf, name):
            DataRMF.__setattr__(rmf, name, val)
        else:
            NoNewAttributesAfterInit.__setattr__(self, name, val)
开发者ID:mirca,项目名称:sherpa,代码行数:11,代码来源:instrument.py

示例8: __init__

    def __init__(self):
        """

        Initialize a Plot object.  All 1D line plot
        instances utilize Plot, which provides a generic
        interface to a backend.

        Once an instance of Plot is initialized no new
        attributes of the class can be made. (To eliminate
        the accidental creation of erroneous attributes)
        
        """
        self.plot_prefs = self.plot_prefs.copy()
        NoNewAttributesAfterInit.__init__(self)
开发者ID:brefsdal,项目名称:sherpa,代码行数:14,代码来源:__init__.py

示例9: __setattr__

 def __setattr__(self, name, val):
     par = getattr(self, name.lower(), None)
     if (par is not None) and isinstance(par, Parameter):
         # When setting an attribute that is a Parameter, set the parameter's
         # value instead.
         par.val = val
     else:
         NoNewAttributesAfterInit.__setattr__(self, name, val)
         if isinstance(val, Parameter):
             # Update parameter index
             self._par_index[val.name.lower()] = val
             if val.aliases:
                 # Update index of aliases, if necessary
                 for alias in val.aliases:
                     self._par_index[alias] = val
开发者ID:DougBurke,项目名称:sherpa,代码行数:15,代码来源:model.py

示例10: __init__

    def __init__(self, fit, results, init_stat, param_warnings):
        _vals   = fit.data.eval_model_to_fit(fit.model)
        _dof    = len(_vals) - len(tuple(results[1]))
        _qval   = None
        _rstat  = None
        _covarerr = results[4].get('covarerr')
        if (isinstance(fit.stat, (CStat,Chi2)) and
            not isinstance(fit.stat, LeastSq)):
            if _dof > 0 and results[2] >= 0.0:
                _qval = igamc(_dof/2., results[2]/2.)
                _rstat = results[2]/_dof
            else:
                _rstat = nan

        self.succeeded    = results[0]
        self.parnames     = tuple(p.fullname for p in fit.model.pars
                                  if not p.frozen)
        self.parvals      = tuple(results[1])
        self.istatval     = init_stat
        self.statval      = results[2]
        self.dstatval     = abs(results[2]-init_stat)
        self.numpoints    = len(_vals)
        self.dof          = _dof
        self.qval         = _qval
        self.rstat        = _rstat
        self.message      = results[3]
        if _covarerr is not None:
            self.covarerr      = tuple(_covarerr)
        else:
            self.covarerr      = None
        self.nfev         = results[4].get('nfev')
        self.extra_output = results[4]
        self.modelvals    = _vals
        self.methodname   = type(fit.method).__name__.lower()
        self.itermethodname = fit._iterfit.itermethod_opts['name']
        statname     = type(fit.stat).__name__.lower()
	if isinstance(fit.stat, Chi2) and not isinstance(fit.stat, LeastSq):
		isSimulFit = isinstance(fit.data, DataSimulFit)
           	if isSimulFit:
			is_error_set = [d.staterror is not None for d in fit.data.datasets]
			if all(is_error_set):
                		statname = 'chi2'
		elif fit.data.staterror is not None:
            		statname = 'chi2'
	self.statname = statname
        self.datasets     = None # To be filled by calling function
        self.param_warnings = param_warnings
        NoNewAttributesAfterInit.__init__(self)
开发者ID:anetasie,项目名称:sherpa-old,代码行数:48,代码来源:fit.py

示例11: __init__

    def __init__(self):
        """

        Initialize a data object.  This method can only be called from
        a derived class constructor.  Attempts to create a BaseData
        instance will raise NotImplementedErr.

        Derived class constructors must call this method directly (and
        not indirectly through a superclass constructor).  When thus
        invoked, this method will extract the argument names and
        values from the derived class constructor invocation and set
        corresponding attributes on the instance (thereby eliminating
        the need for the derived class constructor to do its own
        attribute setting).  If the name of an argument matches the
        name of a DataProperty of the derived class, then the
        corresponding attribute name will have an underscore prepended
        (meaning the property will use the value directly instead of
        relying on _get_*/_set_* methods).

        """

        if type(self) is BaseData:
            raise NotImplementedErr('noinstanceallowed', 'BaseData')

        frame = sys._getframe().f_back
        cond = (frame.f_code is self.__init__.im_func.func_code)
        assert cond, (('%s constructor must call BaseData constructor ' +
                       'directly') % type(self).__name__)
        args = inspect.getargvalues(frame)

        self._fields = tuple(args[0][1:])
        for f in self._fields:
            cond = (f not in vars(self))
            assert cond, (("'%s' object already has attribute '%s'") %
                          (type(self).__name__, f))
            setattr(self, f, args[3][f])

        self.filter = None
        self.mask = True

        NoNewAttributesAfterInit.__init__(self)
开发者ID:OrbitalMechanic,项目名称:sherpa,代码行数:41,代码来源:data.py

示例12: __init__

    def __init__(self, dshape, kshape, norm=False, frozen=True,
                 center=None, args=[], kwargs={},
                 do_pad=False, pad_mask=None, origin=None):

        if origin is None:
            origin = numpy.zeros(len(kshape))
        self.dshape = dshape
        self.kshape = kshape
        self.kernel = None
        self.skshape= None
        self.norm   = norm
        self.origin = origin
        self.frozen = frozen
        self.center = center
        self.args = args
        self.kwargs = kwargs
        self.renorm_shape = None
        self.renorm = None
        self.do_pad = do_pad
        self.pad_mask = pad_mask
        self.frac = None
        self._tcd = tcdData()
        NoNewAttributesAfterInit.__init__(self)
开发者ID:cxcdev,项目名称:sherpa,代码行数:23,代码来源:instrument.py

示例13: __getattr__

    def __getattr__(self, name):
        """Access to parameters is case insensitive."""

        if "_par_index" == name:
            if self.__dict__.get('_par_index') is None:
                self.__dict__['_par_index'] = {}
            return self.__dict__['_par_index']

        lowered_name = name.lower()

        def warn(oname, nname):
            wmsg = 'Parameter name {} is deprecated'.format(oname) + \
                ' for model {}, '.format(type(self).__name__) + \
                'use {} instead'.format(nname)
            warnings.warn(wmsg, DeprecationWarning)

        parameter = self._par_index.get(lowered_name)

        if parameter is not None:
            if lowered_name in parameter.aliases:
                warn(lowered_name, parameter.name)
            return parameter

        NoNewAttributesAfterInit.__getattribute__(self, name)
开发者ID:DougBurke,项目名称:sherpa,代码行数:24,代码来源:model.py

示例14: __setattr__

 def __setattr__(self, name, val):
     if name in self.__dict__.get('config', ()):
         self.config[name] = val
     else:
         NoNewAttributesAfterInit.__setattr__(self, name, val)
开发者ID:anetasie,项目名称:sherpa-old,代码行数:5,代码来源:__init__.py

示例15: __init__

    def __init__(self, name, optfunc):        
        self.name = name
	self._optfunc = optfunc
        self.config = self.default_config
        NoNewAttributesAfterInit.__init__(self)
开发者ID:anetasie,项目名称:sherpa-old,代码行数:5,代码来源:__init__.py


注:本文中的sherpa.utils.NoNewAttributesAfterInit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。