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


Python Solver.Solver类代码示例

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


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

示例1: run

 def run(self):
     while True:
         html = self.opener.open(captcha_url).read().decode()
         captcha_img_url = host + pq(html)("#captcha_image").attr("src")
         captcha_img = self.opener.open(captcha_img_url).read()
         try:
             solver = Solver(Image.open(BytesIO(captcha_img)), captcha_length)
             result = solver.get_result()
             if len(solver.char_areas) != captcha_length:
                 raise IndexError()
         except IndexError:
             self.queue.put(
                 (Image.open(BytesIO(captcha_img)), Image.open(BytesIO(captcha_img)), "------", False, True))
             continue
         payload = {
             "do": "contact",
             "ct_name": "",
             "ct_email": "",
             "ct_URL": "",
             "ct_message": "",
             "ct_captcha": result
         }
         resp = self.opener.open(captcha_url, urlencode(payload).encode()).read().decode()
         print("put!")
         img_data = {
             'pixels': solver.captcha.tobytes(),
             'size': solver.captcha.size,
             'mode': solver.captcha.mode,
         }
         if "captcha was correct" in resp:
             self.queue.put((Image.open(BytesIO(captcha_img)), img_data, result, True, False))
             print('Corr')
         else:
             self.queue.put((Image.open(BytesIO(captcha_img)), img_data, result, False, False))
             print('Wong')
开发者ID:Saren-Arterius,项目名称:securimage-solver,代码行数:35,代码来源:Test.py

示例2: __init__

    def __init__(self,  iters=6000, test='temp', full=True, L=True, OD=True,
                 CP=True, LP=True, eq='CP', init=False, noise=0,
                 method='py_oracle'):
        Solver.__init__(self, test=test, full=full, L=L, OD=OD, CP=CP, LP=LP,
                        eq=eq, init=init, noise=noise, method=method)

        self.iters = iters

        # CS test config
        self.CS_PATH = '/Users/cathywu/Dropbox/Fa13/EE227BT/traffic-project'
        self.OUT_PATH = '%s/' % c.DATA_DIR

        # Test parameters
        # self.method = 'cvx_random_sampling_L1_30_replace'
        # self.method = method  # 'cvx_random_sampling_L1_6000_replace'
        # self.method = 'cvx_oracle'
        # alg = 'cvx_unconstrained_L1'
        # alg = 'cvx_L2'
        # alg = 'cvx_raw'
        # alg = 'cvx_weighted_L1'
        # alg = 'cvx_hot_start_lp'
        # alg = 'cvx_single_block_L_infty'
        # alg = 'cvx_random_sample_L_infty'
        # alg = 'cvx_mult_blocks_L_infty'
        # alg = 'cvx_block_descent_L_infty'
        # alg = 'cvx_entropy'
        self.A, self.b, self.N, self.block_sizes, self.x_true, self.nz, \
            self.flow, self.rsort_index, self.x0 = None, None, None, None, \
            None, None, None, None, None
        self.fname, self.mlab = None, None
开发者ID:megacell,项目名称:traffic-estimation-comparison,代码行数:30,代码来源:SolverCS.py

示例3: __init__

 def __init__(self, name="solvernonlinear"):
   """
   Constructor.
   """
   Solver.__init__(self, name)
   ModuleSolverNonlinear.__init__(self)
   return
开发者ID:geodynamics,项目名称:pylith,代码行数:7,代码来源:SolverNonlinear.py

示例4: mkgoodtrain

def mkgoodtrain():
    wps = open("../all_a.txt").readlines()
    answs = open("../all_aa.txt").readlines()
    goodtrain = open("goodp.txt",'w')
    goodtraina = open("gooda.txt",'w')

    for k in range(len(wps)):
        print(k)
        problem = wps[k].lower()
        try:
            story = nlp.parse(problem)
            numbs = setmaker.setmaker(story)
            numlist = [cleannum(v.num) for k,v in numbs if setmaker.floatcheck(v.num)]
            numlist = [x for x in numlist if x!='']
        except:
            continue
        print(numlist)
        signal.signal(signal.SIGALRM, kill)
        signal.alarm(10)
        try:
            ST = Solver(numlist)
            answers = ST.solveEquations(float(answs[k]))

            print(answers)
        except:
            continue
        if answers != []:
            goodtrain.write(problem)
            goodtraina.write(answs[k])
    goodtrain.close();goodtraina.close()
开发者ID:MathProblems,项目名称:april,代码行数:30,代码来源:mktraindata.py

示例5: __init__

    def __init__(self, name, facility="solver"):
        Solver.__init__(self, name, facility)

        self.coupler = None
        self.myPlus = []
        self.remotePlus = []
        return
开发者ID:drifter-cao,项目名称:citcoms,代码行数:7,代码来源:CoupledSolver.py

示例6: checkpoint

    def checkpoint(self, checkpointFrequency):
        Solver.checkpoint(self, checkpointFrequency)

        if not (self.step % checkpointFrequency):
            #TODO: checkpoint for coupler
            pass
        return
开发者ID:drifter-cao,项目名称:citcoms,代码行数:7,代码来源:CoupledSolver.py

示例7: __init__

 def __init__(self, name="solverlinear"):
   """
   Constructor.
   """
   Solver.__init__(self, name)
   ModuleSolverLumped.__init__(self)
   return
开发者ID:jjle,项目名称:pylith,代码行数:7,代码来源:SolverLumped.py

示例8: _configure

  def _configure(self):
    """
    Set members based using inventory.
    """
    Solver._configure(self)

    ModuleSolverNonlinear.skipNullSpaceCreation(self, not self.createNullSpace)
    return
开发者ID:geodynamics,项目名称:pylith,代码行数:8,代码来源:SolverNonlinear.py

示例9: initialize

    def initialize(self, application):
        Solver.initialize(self, application)

        self.coupler = application.coupler
        self.myPlus = application.myPlus
        self.remotePlus = application.remotePlus

        self.coupler.initialize(self)
        return
开发者ID:drifter-cao,项目名称:citcoms,代码行数:9,代码来源:CoupledSolver.py

示例10: run

 def run(self):
     while True:
         buffer = BytesIO(urlopen(captcha_url).read())
         solver = Solver(Image.open(buffer), captcha_length)
         while len(solver.char_areas) != captcha_length:
             buffer = BytesIO(urlopen(captcha_url).read())
             solver = Solver(Image.open(buffer), captcha_length)
         buffer.seek(0)
         captcha_result = solver.get_result()
         CaptchaGatherThread.captchas.put({"captcha": Image.open(buffer), "solver": solver, "guess": captcha_result})
开发者ID:AllenThePythonic,项目名称:securimage-solver,代码行数:10,代码来源:Main.py

示例11: run

 def run(self):
     while True:
         solver = None
         while solver is None or len(solver.char_areas) != captcha_length:
             rep = urlopen(captcha_url)
             answer = rep.info()['x-captcha-code']
             print(answer)
             buffer = BytesIO(rep.read())
             solver = Solver(Image.open(buffer), captcha_length)
         buffer.seek(0)
         captcha_result = solver.get_result()
         CaptchaGatherThread.captchas.put({"captcha": Image.open(buffer), "solver": solver, "guess": captcha_result, "answer": answer})
         print('Put')
开发者ID:Saren-Arterius,项目名称:securimage-solver,代码行数:13,代码来源:Main.py

示例12: run

 def run(self):
     while True:
         buffer = BytesIO(self.opener.open(captcha_url).read())
         try:
             solver = Solver(Image.open(buffer), captcha_length)
         except Exception as e:
             print("Rate limit exceeded: ", e)
             return
         while len(solver.char_areas) != captcha_length:
             buffer = BytesIO(self.opener.open(captcha_url).read())
             solver = Solver(Image.open(buffer), captcha_length)
         buffer.seek(0)
         captcha_result = solver.get_result()
         CaptchaGatherThread.captchas.put({"captcha": Image.open(buffer), "solver": solver, "guess": captcha_result})
开发者ID:Saren-Arterius,项目名称:hkgolden-captcha-solver,代码行数:14,代码来源:Main.py

示例13: __init__

    def __init__(self, test=None, full=True, L=True, OD=True, CP=True, LP=True,
                 eq='CP', damp=0, noise=0.0):
        Solver.__init__(self)

        self.test = test
        self.eq = eq
        self.full = full
        self.L = L
        self.OD = OD
        self.CP = CP
        self.LP = LP
        self.damp = damp

        self.data, self.A, self.b, self.x0, self.x_true = None, None, None, \
            None, None
开发者ID:megacell,项目名称:traffic-estimation-comparison,代码行数:15,代码来源:SolverLSQR.py

示例14: __init__

 def __init__(self,node_set):
     self.node_set=node_set
     
     #Initialize all the variables
     Initialization.Initialization(self.node_set)
     
     self.solver=Solver(self.node_set)
开发者ID:qiuyupeng,项目名称:DistributedOPFAlg,代码行数:7,代码来源:Algorithm.py

示例15: Interpreter

inter = Interpreter(vectorial =True)
mass = inter.lumped_mass_matrix(simu)
mass = mass[:,0]
print sum(mass)
for node in range(node_coords.shape[0]):
    dofs_past.append(DOF(node, simu, comp = 0, t = 0 * dt))
    dofs_past.append(DOF(node, simu, comp = 1, t = 0 * dt))
    dofs_present.append(DOF(node, simu, comp = 0, t = 1 * dt))
    dofs_present.append(DOF(node, simu, comp = 1, t = 1 * dt))
    dofs_future.append(DOF(node, simu, comp = 0, t = 2 * dt))
    dofs_future.append(DOF(node, simu, comp = 1, t = 2 * dt))

snapshot = [dofs_past, dofs_present, dofs_future]

from numpy import zeros, append, array
solver = Solver()
quads = solver.substract_1(simu.domain.elements.quads.el_set)
quads = quads[:,1:]
field3 =  zeros((simu.domain.nodes.n,3))
for n in times:
    print n
    field = array([])
#    for dof in snapshot[1]:
#        print 'dof.node_id',dof.node_id, 'value', dof.value    
    for dof in range(len(snapshot[0])):
        E_past =  snapshot[0][dof]      
        E_present = snapshot[1][dof]
        E_future = snapshot[2][dof]  
        if E_future.check_if_in_boundary(simu, t = n*dt) == False:
            Fi = E_present.find_surrounding_elements(snapshot[1], simu)
            F = -Fi + 1.0/(dt**2)*mass[dof]*(2*E_present.value - E_past.value)
开发者ID:bebopsan,项目名称:peyeQM,代码行数:31,代码来源:small_post_proc_test3.py


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