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)
def __init__(self, name, datasets, numcores=1): if len(datasets) == 0: raise DataErr('zerodatasimulfit', type(self).__name__) self.name = name self.datasets = tuple(datasets) self.numcores = numcores NoNewAttributesAfterInit.__init__(self)
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)
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)
def __init__(self, name, indep, y, staterror=None, syserror=None): """ Warning: Currently, Data objects ignore any masks on input data. If you have masked data, set ``data.mask`` after initialization - and note that the Sherpa convention for masking is OPPOSITE to numpy, i.e. in Sherpa True marks a valid value and False an invalid, to-be-ignored value. Parameters ---------- name : basestring name of this dataset indep: tuple of array_like the tuple of independent arrays y : array_like the values of the dependent observable staterror : array_like the statistical error associated with the data syserror : array_like the systematic error associated with the data """ self.name = name self._data_space = self._init_data_space(Filter(), *indep) self.y = _check(y) self.staterror = staterror self.syserror = syserror NoNewAttributesAfterInit.__init__(self)
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)
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)
def __init__(self, name, estfunc): self._estfunc = estfunc self.name = name # config should be defined pre-instantiation for pickling # however, for some unknown reason membership in self.__dict__ # requires declaration in __init__() self.config = self.config.copy() NoNewAttributesAfterInit.__init__(self)
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)
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)
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)
def __init__(self, fit, results, parlist = []): if (parlist == []): parlist = [p for p in fit.model.pars if not p.frozen] from sherpa.estmethods import est_success, est_hardmin, est_hardmax, est_hardminmax warning_hmin = "hard minimum hit for parameter " warning_hmax = "hard maximum hit for parameter " self.datasets = None # To be set by calling function self.methodname = type(fit.estmethod).__name__.lower() self.iterfitname = fit._iterfit.itermethod_opts['name'] self.fitname = type(fit.method).__name__.lower() self.statname = type(fit.stat).__name__.lower() self.sigma = fit.estmethod.sigma self.percent = erf(self.sigma / sqrt(2.0)) * 100.0 self.parnames = tuple(p.fullname for p in parlist if not p.frozen) self.parvals = tuple(p.val for p in parlist if not p.frozen) self.parmins = () self.parmaxes = () self.nfits = 0 success = True for i in range(len(parlist)): if (results[2][i] != est_success): success = False if (results[2][i] == est_hardmin or results[2][i] == est_hardminmax): self.parmins = self.parmins + (None,) warning(warning_hmin + self.parnames[i]) else: self.parmins = self.parmins + (results[0][i],) if (results[2][i] == est_hardmax or results[2][i] == est_hardminmax): self.parmaxes = self.parmaxes + (None,) warning(warning_hmax + self.parnames[i]) else: self.parmaxes = self.parmaxes + (results[1][i],) self.nfits = results[3] self.extra_output = results[4] NoNewAttributesAfterInit.__init__(self)
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)
def __init__(self, data, model, stat=None, method=None, estmethod=None, itermethod_opts={'name':'none'}): self.data = data self.model = model if stat is None: stat = Chi2Gehrels() if method is None: method = LevMar() if estmethod is None: estmethod = Covariance() self.stat = stat self.method = method self.estmethod = estmethod # Confidence limit code freezes one parameter # at a time. Keep a record here of which one # that is, in case an exception is raised and # this parameter needs to be thawed in the # exception handler. self.thaw_indices = () iter = 0 for current_par in self.model.pars: if current_par.frozen is True: pass else: self.thaw_indices = self.thaw_indices + (iter,) iter = iter + 1 self.current_frozen = -1 # The number of times that reminimization has occurred # during an attempt to compute confidence limits. If # that number equals self.estmethod.maxfits, cease all # further attempt to reminimize. self.refits = 0 # Set up an IterFit object, so that the user can select # an iterative fitting option. self._iterfit = IterFit(self.data, self.model, self.stat, self.method, itermethod_opts) NoNewAttributesAfterInit.__init__(self)
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)
def __init__(self, name, indep, y, staterror=None, syserror=None): """ Parameters ---------- name : basestring name of this dataset indep: tuple of array_like the tuple of independent arrays y : array_like the values of the dependent observable staterror : array_like the statistical error associated with the data syserror : array_like the systematic error associated with the data """ self.name = name self._data_space = self._init_data_space(Filter(), *indep) self.y = _check(y) self.staterror = staterror self.syserror = syserror NoNewAttributesAfterInit.__init__(self)
def __init__(self, name, indep, y, staterror=None, syserror=None): """ Parameters ---------- name : basestring name of this dataset indep: tuple of array_like the tuple of independent arrays. y : array_like The values of the dependent observable. If this is a numpy masked array, the mask will used to initialize a mask. staterror : array_like the statistical error associated with the data syserror : array_like the systematic error associated with the data """ self.name = name self._data_space = self._init_data_space(Filter(), *indep) self.y, self.mask = _check_dep(y) self.staterror = _check_err(staterror, y) self.syserror = _check_err(syserror, y) NoNewAttributesAfterInit.__init__(self)
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)
def __init__(self): NoNewAttributesAfterInit.__init__(self)
def __init__(self, pha, pileup_model): self.pha = pha self.pileup_model = pileup_model NoNewAttributesAfterInit.__init__(self)
def __init__(self): self.scale = ParameterScaleMatrix() NoNewAttributesAfterInit.__init__(self)
def __init__(self): self.__header = {} NoNewAttributesAfterInit.__init__(self)
def __init__(self, rmf, pha=None, arf=None): self._rmf = rmf self._arf = arf self._pha = pha NoNewAttributesAfterInit.__init__(self)
def __init__(self, name, optfunc): self.name = name self._optfunc = optfunc self.config = self.default_config NoNewAttributesAfterInit.__init__(self)
def __init__(self, name, pars=()): self.name = name self.type = self.__class__.__name__.lower() self.pars = tuple(pars) NoNewAttributesAfterInit.__init__(self)
def __init__(self, name, pars=()): self.name = name self.type = self.__class__.__name__.lower() self.pars = tuple(pars) self.is_discrete = False NoNewAttributesAfterInit.__init__(self)
def __init__(self, data, model): self.data = data self.model = model NoNewAttributesAfterInit.__init__(self) return
def __init__(self, name): self.name = name NoNewAttributesAfterInit.__init__(self)
def __init__(self): self.x = 1 self.y = 2 self.z = 3 del self.z NoNewAttributesAfterInit.__init__(self)