當前位置: 首頁>>代碼示例>>Python>>正文


Python parameter.Parameter類代碼示例

本文整理匯總了Python中parameter.Parameter的典型用法代碼示例。如果您正苦於以下問題:Python Parameter類的具體用法?Python Parameter怎麽用?Python Parameter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Parameter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Gauss1D

class Gauss1D(ArithmeticModel):

    def __init__(self, name='gauss1d'):
        self.fwhm = Parameter(name, 'fwhm', 10, tinyval, hard_min=tinyval)
        self.pos = Parameter(name, 'pos', 0)
        self.ampl = Parameter(name, 'ampl', 1)
        ArithmeticModel.__init__(self, name, (self.fwhm, self.pos, self.ampl))

    def get_center(self):
        return (self.pos.val,)

    def set_center(self, pos, *args, **kwargs):
        self.pos.set(pos)

    def guess(self, dep, *args, **kwargs):
        norm = guess_amplitude(dep, *args)
        pos = get_position(dep, *args)
        fwhm = guess_fwhm(dep, *args)
        param_apply_limits(norm, self.ampl, **kwargs)
        param_apply_limits(pos, self.pos, **kwargs)
        param_apply_limits(fwhm, self.fwhm, **kwargs)

    @modelCacher1d
    def calc(self, *args, **kwargs):
        kwargs['integrate']=bool_cast(self.integrate)
        return _modelfcts.gauss1d(*args, **kwargs)
開發者ID:cxcdev,項目名稱:sherpa,代碼行數:26,代碼來源:basic.py

示例2: Delta2D

class Delta2D(ArithmeticModel):

    def __init__(self, name='delta2d'):
        self.xpos = Parameter(name, 'xpos', 0)
        self.ypos = Parameter(name, 'ypos', 0)
        self.ampl = Parameter(name, 'ampl', 1)
        ArithmeticModel.__init__(self, name, (self.xpos, self.ypos, self.ampl))
        self.cache = 0

    def get_center(self):
        return (self.xpos.val, self.ypos.val)

    def set_center(self, xpos, ypos, *args, **kwargs):
        self.xpos.set(xpos)
        self.ypos.set(ypos)

    def guess(self, dep, *args, **kwargs):
        xpos, ypos = guess_position(dep, *args)
        norm = guess_amplitude2d(dep, *args)
        param_apply_limits(xpos, self.xpos, **kwargs)
        param_apply_limits(ypos, self.ypos, **kwargs)
        param_apply_limits(norm, self.ampl, **kwargs)


    def calc(self, *args, **kwargs):
        kwargs['integrate']=bool_cast(self.integrate)
        return _modelfcts.delta2d(*args, **kwargs)
開發者ID:cxcdev,項目名稱:sherpa,代碼行數:27,代碼來源:basic.py

示例3: NormGauss1D

class NormGauss1D(ArithmeticModel):

    def __init__(self, name='normgauss1d'):
        self.fwhm = Parameter(name, 'fwhm', 10, tinyval, hard_min=tinyval)
        self.pos = Parameter(name, 'pos', 0)
        self.ampl = Parameter(name, 'ampl', 1)
        ArithmeticModel.__init__(self, name, (self.fwhm, self.pos, self.ampl))

    def get_center(self):
        return (self.pos.val,)

    def set_center(self, pos, *args, **kwargs):
        self.pos.set(pos)

    def guess(self, dep, *args, **kwargs):
        ampl = guess_amplitude(dep, *args)
        pos = get_position(dep, *args)
        fwhm = guess_fwhm(dep, *args)
        param_apply_limits(pos, self.pos, **kwargs)
        param_apply_limits(fwhm, self.fwhm, **kwargs)

        # Apply normalization factor to guessed amplitude
        norm = numpy.sqrt(numpy.pi/_gfactor)*self.fwhm.val
        for key in ampl.keys():
            if ampl[key] is not None:
                ampl[key] *= norm
        param_apply_limits(ampl, self.ampl, **kwargs)

    @modelCacher1d
    def calc(self, *args, **kwargs):
        kwargs['integrate']=bool_cast(self.integrate)
        return _modelfcts.ngauss1d(*args, **kwargs)
開發者ID:cxcdev,項目名稱:sherpa,代碼行數:32,代碼來源:basic.py

示例4: Gauss2D

class Gauss2D(ArithmeticModel):

    def __init__(self, name='gauss2d'):
        self.fwhm = Parameter(name, 'fwhm', 10, tinyval, hard_min=tinyval)
        self.xpos = Parameter(name, 'xpos', 0)
        self.ypos = Parameter(name, 'ypos', 0)
        self.ellip = Parameter(name, 'ellip', 0, 0, 0.999, 0, 0.9999,
                               frozen=True)
        self.theta = Parameter(name, 'theta', 0, 0, 2*numpy.pi, -2*numpy.pi,
                               4*numpy.pi, 'radians', frozen=True)
        self.ampl = Parameter(name, 'ampl', 1)
        ArithmeticModel.__init__(self, name,
                                 (self.fwhm, self.xpos, self.ypos, self.ellip,
                                  self.theta, self.ampl))
        self.cache = 0

    def get_center(self):
        return (self.xpos.val, self.ypos.val)

    def set_center(self, xpos, ypos, *args, **kwargs):
        self.xpos.set(xpos)
        self.ypos.set(ypos)

    def guess(self, dep, *args, **kwargs):
        xpos, ypos = guess_position(dep, *args)
        norm = guess_amplitude2d(dep, *args)
        param_apply_limits(xpos, self.xpos, **kwargs)
        param_apply_limits(ypos, self.ypos, **kwargs)
        param_apply_limits(norm, self.ampl, **kwargs)


    def calc(self, *args, **kwargs):
        kwargs['integrate']=bool_cast(self.integrate)
        return _modelfcts.gauss2d(*args, **kwargs)
開發者ID:cxcdev,項目名稱:sherpa,代碼行數:34,代碼來源:basic.py

示例5: __init__

    def __init__(self):
        # Parameters
        self.charging_current_limit = 5
        self.gyro_limit = 0.15
        self.min_number_of_values_over_limit = 25
        self.array_length = 90
        self.min_trip_length = 300 #s
        self.trip_started = False
        self.max_time_between_movement = 280 #s
        self.max_avg_speed = 30 #km/h

        # Declaring variables
        self.charging_currents = Parameter(self.array_length, self.charging_current_limit, self.min_number_of_values_over_limit)
        self.gyroscopes = Parameter(self.array_length, self.gyro_limit, self.min_number_of_values_over_limit)
        self.start_times = []
        self.end_times = []

        # Declaring temporary variable for trips
        self.tmp_start_time = 0

        # Defining positions of variables in DB
        self.time_db = 0
        # latGPS_db = 3
        # lenGPS_db = 4
        self.charging_current_db = 26
        self.gyro_x_db = 13
        self.gyro_y_db = 14
        self.gyro_z_db = 15
開發者ID:TongLin1995,項目名稱:webike,代碼行數:28,代碼來源:tripDetection.py

示例6: initialize

 def initialize(self):
     parameters = []
     configure_parameters = self.configure.get(self.name)
     if type(configure_parameters) is list:
         parameters.extend(configure_parameters)
     else:
         parameters.append(configure_parameters)
     files=listdir(self.path)
     for parameterName in parameters:
         ##for example cpu.shares then it will start with cpu, we only configure these files.
         if parameterName in files:
             ##we pass the path fo the file under this subsystem to Parameter class 
             fileName = self.path+"/"+parameterName
             
             parameter = Parameter(name=parameterName,
                                   path=fileName,
                                   configure=self.configure)
             self.subParameters[parameterName]=parameter
         else:
             log.error("can not find file parameter %s",parameterName)
             ##TODO we can't find a file mathed with parameter log error message here
             pass
         ##read initial values
     for parameter in self.subParameters.values():
         parameter.read()
開發者ID:yncxcw,項目名稱:MRDocker,代碼行數:25,代碼來源:cgroup.py

示例7: __init__

 def __init__(self, name="normgauss2d"):
     self.fwhm = Parameter(name, "fwhm", 10, tinyval, hard_min=tinyval)
     self.xpos = Parameter(name, "xpos", 0)
     self.ypos = Parameter(name, "ypos", 0)
     self.ellip = Parameter(name, "ellip", 0, 0, 0.999, 0, 0.9999, frozen=True)
     self.theta = Parameter(
         name, "theta", 0, -2 * numpy.pi, 2 * numpy.pi, -2 * numpy.pi, 4 * numpy.pi, "radians", frozen=True
     )
     self.ampl = Parameter(name, "ampl", 1)
     ArithmeticModel.__init__(self, name, (self.fwhm, self.xpos, self.ypos, self.ellip, self.theta, self.ampl))
     self.cache = 0
開發者ID:OrbitalMechanic,項目名稱:sherpa,代碼行數:11,代碼來源:basic.py

示例8: __init__

 def __init__(self, name='normgauss2d'):
     self.fwhm = Parameter(name, 'fwhm', 10, tinyval, hard_min=tinyval)
     self.xpos = Parameter(name, 'xpos', 0)
     self.ypos = Parameter(name, 'ypos', 0)
     self.ellip = Parameter(name, 'ellip', 0, 0, 0.999, 0, 0.9999,
                            frozen=True)
     self.theta = Parameter(name, 'theta', 0, 0, 2*numpy.pi, -2*numpy.pi,
                            4*numpy.pi, 'radians', frozen=True)
     self.ampl = Parameter(name, 'ampl', 1)
     ArithmeticModel.__init__(self, name,
                              (self.fwhm, self.xpos, self.ypos, self.ellip,
                               self.theta, self.ampl))
     self.cache = 0
開發者ID:cxcdev,項目名稱:sherpa,代碼行數:13,代碼來源:basic.py

示例9: __init__

    def __init__(self, name, parts):
	self.parts = tuple(parts)

	allpars = []
	for part in self.parts:
            for p in part.pars:
                if p in allpars:
                    # If we already have a reference to this parameter, store
                    # a hidden, linked proxy instead
                    pnew = Parameter(p.modelname, p.name, 0.0, hidden=True)
                    pnew.link = p
                    p = pnew
                allpars.append(p)

	Model.__init__(self, name, allpars)
開發者ID:anetasie,項目名稱:sherpa-old,代碼行數:15,代碼來源:model.py

示例10: inject

    def inject(cls, cmd):
        if isinstance(cmd, type):
            if issubclass(cmd, Action):
                return A_CMD(cmd)
        if isinstance(cmd, CLI_CMD):
            return cmd
        elif isinstance(cmd, str):
            return LIT_CMD(cmd)
        elif isinstance(cmd, Message):
            return MESSAGE_CMD(cmd)
        elif isinstance(cmd, dict):
            return ASSIGN_CMD(**cmd)
        elif isinstance(cmd, Delete):
            return ENVIRONMENT_DEL_CMD(*cmd.keys)
        elif isinstance(cmd, GetVariable):
            return ENVIRONMENT_CMD(cmd.name)
        elif isinstance(cmd, GeneratorType):
            return GEN_CMD(cmd)
        elif isinstance(cmd, tuple):
            return PAR_CMD(*cmd)

        try:
            cmd = Parameter.inject(cmd)
            return PAR_INP(cmd)
        except:
            pass

        raise TypeError('invalid command value: {} '
                        '(type: {})'.format(cmd, type(cmd)))
開發者ID:IARI,項目名稱:asp_grader,代碼行數:29,代碼來源:cli.py

示例11: NormGauss2D

class NormGauss2D(ArithmeticModel):

    def __init__(self, name='normgauss2d'):
        self.fwhm = Parameter(name, 'fwhm', 10, tinyval, hard_min=tinyval)
        self.xpos = Parameter(name, 'xpos', 0)
        self.ypos = Parameter(name, 'ypos', 0)
        self.ellip = Parameter(name, 'ellip', 0, 0, 0.999, 0, 0.9999,
                               frozen=True)
        self.theta = Parameter(name, 'theta', 0, 0, 2*numpy.pi, -2*numpy.pi,
                               4*numpy.pi, 'radians', frozen=True)
        self.ampl = Parameter(name, 'ampl', 1)
        ArithmeticModel.__init__(self, name,
                                 (self.fwhm, self.xpos, self.ypos, self.ellip,
                                  self.theta, self.ampl))
        self.cache = 0

    def get_center(self):
        return (self.xpos.val, self.ypos.val)

    def set_center(self, xpos, ypos, *args, **kwargs):
        self.xpos.set(xpos)
        self.ypos.set(ypos)

    def guess(self, dep, *args, **kwargs):
        xpos, ypos = guess_position(dep, *args)
        ampl = guess_amplitude2d(dep, *args)
        param_apply_limits(xpos, self.xpos, **kwargs)
        param_apply_limits(ypos, self.ypos, **kwargs)

        # Apply normalization factor to guessed amplitude
        norm = (numpy.pi/_gfactor)*self.fwhm.val*self.fwhm.val*numpy.sqrt(1.0 - (self.ellip.val*self.ellip.val))
        for key in ampl.keys():
            if ampl[key] is not None:
                ampl[key] *= norm
        param_apply_limits(ampl, self.ampl, **kwargs)


    def calc(self, *args, **kwargs):
        kwargs['integrate']=bool_cast(self.integrate)
        return _modelfcts.ngauss2d(*args, **kwargs)
開發者ID:cxcdev,項目名稱:sherpa,代碼行數:40,代碼來源:basic.py

示例12: Delta1D

class Delta1D(ArithmeticModel):
    def __init__(self, name="delta1d"):
        self.pos = Parameter(name, "pos", 0)
        self.ampl = Parameter(name, "ampl", 1)
        ArithmeticModel.__init__(self, name, (self.pos, self.ampl))

    def get_center(self):
        return (self.pos.val,)

    def set_center(self, pos, *args, **kwargs):
        self.pos.set(pos)

    def guess(self, dep, *args, **kwargs):
        norm = guess_amplitude(dep, *args)
        pos = get_position(dep, *args)
        param_apply_limits(norm, self.ampl, **kwargs)
        param_apply_limits(pos, self.pos, **kwargs)

    @modelCacher1d
    def calc(self, *args, **kwargs):
        kwargs["integrate"] = bool_cast(self.integrate)
        return _modelfcts.delta1d(*args, **kwargs)
開發者ID:OrbitalMechanic,項目名稱:sherpa,代碼行數:22,代碼來源:basic.py

示例13: __init__

    def __init__(self, name, parts):
        self.parts = tuple(parts)
        allpars = []
        for part in self.parts:
            for p in part.pars:
                if p in allpars:
                    # If we already have a reference to this parameter, store
                    # a hidden, linked proxy instead
                    pnew = Parameter(p.modelname, p.name, 0.0, hidden=True)
                    pnew.link = p
                    p = pnew
                allpars.append(p)

        Model.__init__(self, name, allpars)

        for part in self.parts:
            try:
                self.is_discrete = self.is_discrete or part.is_discrete
            except:
                warning("Could not determine whether the model is discrete.\n"+
                        "This probably means that you have restored a session saved with a previous version of Sherpa.\n"+
                        "Falling back to assuming that the model is continuous.\n")
                self.is_discrete = False
開發者ID:OrbitalMechanic,項目名稱:sherpa,代碼行數:23,代碼來源:model.py

示例14: parse

    def parse(tkns):
        """ Parse a verilog module
            module :=
                'module' identifier [module_param_port_list] [list_of_ports]
                    ';' {module_item} 'endmodule'
                | 'module' identifier [module_param_port_list]
                    [list_of_port_declarations] ';' {non_port_module_item}
                    'endmodule'
        """
        tkns.expect(Tokens.KW_MODULE)

        # get module name
        name = tkns.current().text
        tkns.expect(Tokens.IDENTIFIER)

        # get parameter port list, if it exists
        params = []
        if tkns.check(Tokens.HASH):
            params = Parameter.parse_module_param_port_list(tkns)

        # get i/o port list, if it exists
        io = []
        if tkns.check(Tokens.OPEN_PAREN):
            if tkns.peek(Tokens.CLOSE_PAREN):
                tkns.next()
                tkns.next()
            elif tkns.peek(Tokens.KW_INOUT) or tkns.peek(Tokens.KW_INPUT) or tkns.peek(Tokens.KW_OUTPUT):
                io = Port.parse_list_of_port_declarations(tkns)
            else:
                io = Port.parse_list_of_ports(tkns)

        # get module contents
        # TODO: look at contents for more parameters, do other parsing
        contents = []
        while not tkns.accept(Tokens.KW_ENDMODULE):
            contents.append(tkns.next())

        return Module(name, params, io, contents)
開發者ID:pdear,項目名稱:verilib,代碼行數:38,代碼來源:module.py

示例15: open

               for x in open("contain-angle-quotes.csv")]

def title_index(lst, title):
    try:
        return lst.index(title)
    except Exception:
        return -1

def generate_csv_list(clm1, index, title_lst):
    line_count = max(len(clm1), len(title_lst), 1)
    column1 = clm1 + ['']*(line_count-1)
    column2 = [index+1] + ['']*(line_count-1)
    column3 = title_lst + ['']*(line_count-len(title_lst))
    return zip(column1, column2, column3)

Parameter.setEnv('kevin')
simpleRes = LncSimpleSearchResultTestCase()

csv_output_filename = "angle-quotes-results.csv"
csv_output_file = open(csv_output_filename, "a")

for legal in legislation:
    for tag in legal[2:]:
        cur_titles = simpleRes.get_results_list(tag)
        index = title_index(cur_titles, legal[1])
        
        csv_line = generate_csv_list([tag, legal[1], legal[0]], index, cur_titles)
        
        for cl in csv_line:
            line = ("%s\t%s\t%s\n" % cl)
            csv_output_file.write(line.encode('utf-8'))
開發者ID:kevindragon,項目名稱:lnc_testing,代碼行數:31,代碼來源:compare-angle-quotes.py


注:本文中的parameter.Parameter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。