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


Python params.Params類代碼示例

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


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

示例1: test_node

  def test_node (self):
    """Upload a skeleton node and test it's fields"""

    # Make a node
    makeAnno (p, 7)

    # test the nodetype
    nodetype = random.randint (0,100)
    f = setField(p, 'nodetype', nodetype)
    f = getField(p, 'nodetype')
    assert nodetype == int(f.content)

    # test the skeletonid
    skeletonid = random.randint (0,65535)
    f = setField(p, 'skeletonid', skeletonid)
    f = getField(p, 'skeletonid')
    assert skeletonid == int(f.content)

    # test the pointid
    pointid = random.randint (0,65535)
    f = setField(p, 'pointid', pointid)
    f = getField(p, 'pointid')
    assert pointid == int(f.content)

    # test the parentid
    parentid = random.randint (0,65535)
    f = setField(p, 'parentid', parentid)
    f = getField(p, 'parentid')
    assert parentid == int(f.content)

    # test the radius
    radius = random.random()
    f = setField(p, 'radius', radius)
    f = getField(p, 'radius')
    assert abs(radius - float(f.content)) < 0.001

    # test the location
    location = [random.random(), random.random(), random.random()]
    f = setField(p, 'location', ','.join([str(i) for i in location]))
    f = getField(p, 'location')
    assert ','.join([str(i) for i in location]) == f.content

    # make a bunch of children
    q = Params()
    q.token = 'unittest'
    q.resolution = 0
    q.channels = ['unit_anno']

    childids = []
    for i in range(0,4):
      makeAnno ( q, 9)
      f = setField(q, 'parent', p.annoid)
      childids.append(q.annoid)

    # Test children
    f = getField(p, 'children')
    rchildids = f.content.split(',')
    for cid in rchildids:
      assert int(cid) in childids
    assert len(rchildids) == 4
開發者ID:neurodata,項目名稱:ndstore,代碼行數:60,代碼來源:test_ramon.py

示例2: test_roi

  def test_roi (self):
    """Upload an roi and test it's fields"""

    # Make a skeleton
    makeAnno (p, 9)

    # test the parent
    parent = random.randint (0,65535)
    f = setField(p, 'parent', parent)
    f = getField(p, 'parent')
    assert parent == int(f.content)

    # make a bunch of children ROIs
    q = Params()
    q.token = 'unittest'
    q.resolution = 0
    q.channels = ['unit_anno']

    childids = []
    for i in range(0,4):
      makeAnno ( q, 9)
      f = setField(q, 'parent', p.annoid)
      childids.append(q.annoid)

    # Test children
    f = getField(p, 'children')
    rchildids = f.content.split(',')
    for cid in rchildids:
      assert int(cid) in childids
    assert len(rchildids) == 4
開發者ID:neurodata,項目名稱:ndstore,代碼行數:30,代碼來源:test_ramon.py

示例3: main

def main():
    # Read Params
    parser = argparse.ArgumentParser()
    parser.add_argument("-s" , "--solver", default="Jacobi", help="one of Jacobi, Gauss, SOR")
    parser.add_argument("-w" , "--omega" , default="1.0", help="w for SOR")
    parser.add_argument("-x" , "--length" , default="1.0", help="Length of one side of domain")
    args = parser.parse_args()
    P = Params("params.txt")
    P.solver = args.solver
    P.Lx = P.Ly = P.Lz = float(args.length)
    P.omega = args.omega
    P.set_dependent()

    # Initialize Domain
    dom_initial = conditions.initial_domain()

    # Assign Solver
    solver = {'Jacobi': solvers.Jacobi, 'Gauss': solvers.Gauss, 'SOR': solvers.SOR}[P.solver]

    # Assign Driver
    driver = drivers.CN(solver)

    # Assign Boundary
    boundary = boundaries.Dirichlet()

    # Run it!
    tic = time.clock()
    dom_final, meaniters = evolve(dom_initial, driver, boundary)
    print (time.clock() - tic) / P.nSteps, meaniters

    # Plot it!
    if (P.plot):
        plot(dom_initial, dom_final)
開發者ID:xmonkee,項目名稱:NumericalMethods,代碼行數:33,代碼來源:main.py

示例4: submit_env

def submit_env(request):
    params = Params( request.POST )
    
    w2sDict = { 'X7_Q':'X7_Q_W2S', 'X7_E':'X7_E_W2S', 'X7_RK':'X7_PK_W2S' }
    client = MqClient( w2sDict )
    client.connect()
    client.send( params.json() )      
    s2wDict = { 'X7_Q':'X7_Q_S2W', 'X7_E':'X7_E_S2W', 'X7_RK':'X7_PK_S2W' }
    srv = MqServer(None,s2wDict)
    srv.connect()
    return render_to_response('init/progress.html')
開發者ID:k3coby,項目名稱:xeven,代碼行數:11,代碼來源:views.py

示例5: MakeModel

 def MakeModel(self, layer):
   params = Params()
   params.num_scales = self.NUM_SCALES
   params.s1_num_orientations = self.NUM_ORIENTATIONS
   model = Model(params = params)
   L = model.Layer
   if layer in (L.S2, L.C2, L.IT):
     # Make uniform-random S2 kernels
     kernel_shape = (self.NUM_PROTOTYPES,) + model.s2_kernel_shape
     kernels = np.random.uniform(0, 1, size = kernel_shape)
     for k in kernels:
       k /= np.linalg.norm(k)
     model.s2_kernels = kernels
   return model
開發者ID:mandaarp,項目名稱:thesis,代碼行數:14,代碼來源:model_test.py

示例6: __init__

    def __init__(self, answers, APP, dryrun = False, debug = False, **kwargs):

        self.debug = debug
        self.dryrun = dryrun
        self.kwargs = kwargs
        if "answers_output" in kwargs:
            self.answers_output = kwargs["answers_output"]

        if os.environ and "IMAGE" in os.environ:
            self.app_path = APP
            APP = os.environ["IMAGE"]
            del os.environ["IMAGE"]

        if APP and os.path.exists(APP):
            self.app_path = APP
        else:
            self.app_path = os.getcwd()
            install = Install(answers, APP, dryrun = dryrun, target_path = self.app_path)
            install.install()

        self.params = Params(target_path=self.app_path)
        if "ask" in kwargs:
            self.params.ask = kwargs["ask"]

        self.utils = Utils(self.params)

        self.answers_file = answers
        self.plugin = Plugin()
        self.plugin.load_plugins()
開發者ID:mscherer,項目名稱:atomicapp,代碼行數:29,代碼來源:run.py

示例7: __init__

    def __init__(self, answers, APP, nodeps = False, update = False, target_path = None, dryrun = False, **kwargs):
        run_path = os.path.dirname(os.path.realpath(__file__))
        self.dryrun = dryrun
        recursive = not nodeps

        app = APP #FIXME

        self.params = Params(recursive, update, target_path)
        self.utils = utils.Utils(self.params)

        if os.path.exists(app):
            logger.info("App path is %s, will be populated to %s" % (app, target_path))
            app = self.utils.loadApp(app)
        else:
            logger.info("App name is %s, will be populated to %s" % (app, target_path))
            
        if not target_path:
            if self.params.app_path:
                self.params.target_path = self.params.app_path
            else: 
                self.params.target_path = os.getcwd()

        self.params.app = app

        self.answers_file = answers
開發者ID:whitel,項目名稱:atomic-app-with-runner,代碼行數:25,代碼來源:install.py

示例8: __init__

    def __init__(self, name, schema = None, dryrun = False):
        self.name = name
        self.app_id = self._nameToId(name)
        self.dryrun = dryrun
        self.schema_path = schema

        if not self.schema_path:
            self.schema_path = SCHEMA_URL

        self.params = Params()
        self.params.app = self.app_id
開發者ID:sub-mod,項目名稱:atomicapp,代碼行數:11,代碼來源:create.py

示例9: test_neuron

  def test_neuron (self):
    """Upload a neuron and test it's fields"""

    # Make a neuron
    makeAnno (p, 5)

    # make a bunch of segments and add to the neuron
    q = Params()
    q.token = 'unittest'
    q.resolution = 0
    q.channels = ['unit_anno']

    segids = []
    for i in range(0,5):
      makeAnno ( q, 4)
      f = setField(q, 'neuron', p.annoid)
      segids.append(q.annoid)

    # Test segments
    f = getField(p, 'segments')
    rsegids = f.content.split(',')
    for sid in rsegids:
      assert int(sid) in segids
    assert len(rsegids) == 5
開發者ID:neurodata,項目名稱:ndstore,代碼行數:24,代碼來源:test_ramon.py

示例10: gibbs_doc

def gibbs_doc(model, doc, params = None, callback = None):
  """Runs Gibbs iterations on a single document, by sampling with a prior constructed from each sample in the given Model. params applies to each sample, so should probably be much more limited than usual - the default if its undefined is to use 1 run and 1 sample and a burn in of only 500. Returns a DocModel with all the relevant samples in."""
  
  # Initialisation stuff - handle params, create the state and the DocModel object, plus a reporter...
  if params==None:
    params = Params()
    params.runs = 1
    params.samples = 1
    params.burnIn = 500

  state = State(doc, params)
  dm = DocModel()
  reporter = ProgReporter(params,callback,model.sampleCount())

  # Iterate and run for each sample in the model...
  for sample in model.sampleList():
    tempState = State(state)
    tempState.setGlobalParams(sample)
    tempState.addPrior(sample)
    gibbs_run(tempState,reporter.next)
    dm.addFrom(tempState.getModel())

  # Return...
  return dm
開發者ID:PeterZhouSZ,項目名稱:helit,代碼行數:24,代碼來源:solve_weave.py

示例11: __init__

    def __init__(self, answers, APP, dryrun = False, debug = False, **kwargs):

        self.debug = debug
        self.dryrun = dryrun
        self.kwargs = kwargs
        if "answers_output" in kwargs:
            self.answers_output = kwargs["answers_output"]

        if APP and os.path.exists(APP):
            self.app_path = APP
        else:
            raise Exception("App path %s does not exist." % APP)

        self.params = Params(target_path=self.app_path)
        if "ask" in kwargs:
            self.params.ask = kwargs["ask"]

        self.utils = Utils(self.params)

        self.answers_file = answers
        self.plugin = Plugin()
        self.plugin.load_plugins()
開發者ID:whitel,項目名稱:atomic-app-with-runner,代碼行數:22,代碼來源:run.py

示例12: compute_inside

 def compute_inside(weights, data, dropout=True):
     params = Params()
     params.feed(weights)
     nn_types.USE_DROPOUT = dropout
     return network.forward_pass(data, params)
開發者ID:glapul,項目名稱:neural_networks,代碼行數:5,代碼來源:nn_helpers.py

示例13: Params

import random
import csv
import numpy as np
import pytest
import httplib
from contextlib import closing

from params import Params
from postmethods import putAnnotation, getAnnotation, getURL, postURL
import kvengine_to_test
import site_to_test
import makeunitdb
SITE_HOST = site_to_test.site


p = Params()
p.token = 'unittest'
p.resolution = 0
p.channels = ['unit_anno']


def H5AnnotationFile ( annotype, annoid, kv=None ):
  """Create an HDF5 file and populate the fields. Return a file object.
      This is a support routine for all the RAMON tests."""

  # Create an in-memory HDF5 file
  tmpfile = tempfile.NamedTemporaryFile()
  h5fh = h5py.File ( tmpfile.name )

  # Create the top level annotation id namespace
  idgrp = h5fh.create_group ( str(annoid) )
開發者ID:nagyistge,項目名稱:ndstore,代碼行數:31,代碼來源:ramon.py

示例14: Params

import tempfile
import h5py
import urllib2
import zlib
import cStringIO
import blosc
import time

sys.path += [os.path.abspath('../django/')]
import OCP.settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'ocpblaze.settings'

from ocplib import MortonXYZ
from params import Params

p = Params()
p.token = "blaze"
p.resolution = 0
p.channels = ['image']
p.window = [0,0]
p.channel_type = "image"
p.datatype = "uint32"
SIZE = 1024
ZSIZE = 16

def generateURL(zidx):
  """Run the Benchmark."""

  i = zidx
  [x,y,z] = MortonXYZ(i)
  p.args = (x*SIZE, (x+1)*SIZE, y*SIZE, (y+1)*SIZE, z*ZSIZE, (z+1)*ZSIZE)
開發者ID:j6k4m8,項目名稱:ndstore,代碼行數:31,代碼來源:benchmark.py

示例15: Run

class Run():
    debug = False
    dryrun = False
    params = None
    answers_data = {GLOBAL_CONF: {}}
    tmpdir = None
    answers_file = None
    provider = DEFAULT_PROVIDER
    installed = False
    plugins = []
    update = False
    app_path = None
    target_path = None
    app_id = None
    app = None
    answers_output = None
    kwargs = None

    def __init__(self, answers, APP, dryrun = False, debug = False, **kwargs):

        self.debug = debug
        self.dryrun = dryrun
        self.kwargs = kwargs
        if "answers_output" in kwargs:
            self.answers_output = kwargs["answers_output"]

        if APP and os.path.exists(APP):
            self.app_path = APP
        else:
            raise Exception("App path %s does not exist." % APP)

        self.params = Params(target_path=self.app_path)
        if "ask" in kwargs:
            self.params.ask = kwargs["ask"]

        self.utils = Utils(self.params)

        self.answers_file = answers
        self.plugin = Plugin()
        self.plugin.load_plugins()

    def _dispatchGraph(self):
        if not "graph" in self.params.mainfile_data:
            raise Exception("Graph not specified in %s" % MAIN_FILE)

        for component, graph_item in self.params.mainfile_data["graph"].iteritems():
            if self.utils.isExternal(graph_item):
                component_run = Run(self.answers_file, self.utils.getExternalAppDir(component), self.dryrun, self.debug, **self.kwargs)
                ret = component_run.run()
                if self.answers_output:
                    self.params.loadAnswers(ret)
            else:
                self._processComponent(component, graph_item)

    def _applyTemplate(self, data, component):
        template = Template(data)
        config = self.params.getValues(component)
        logger.debug("Config: %s " % config)

        output = None
        while not output:
            try:
                logger.debug(config)
                output = template.substitute(config)
            except KeyError as ex:
                name = ex.args[0]
                logger.debug("Artifact contains unknown parameter %s, asking for it" % name)
                config[name] = self.params._askFor(name, {"description": "Missing parameter '%s', provide the value or fix your %s" % (name, MAIN_FILE)})
                if not len(config[name]):
                    raise Exception("Artifact contains unknown parameter %s" % name)
                self.params.loadAnswers({component: {name: config[name]}})

        return output

    def _processComponent(self, component, graph_item):
        logger.debug("Processing component %s" % component)
        
        data = None
        artifacts = self.utils.getArtifacts(component)
        artifact_provider_list = []
        if not self.params.provider in artifacts:
            raise Exception("Data for provider \"%s\" are not part of this app" % self.params.provider)
        
        dst_dir = os.path.join(self.utils.tmpdir, component)
        for artifact in artifacts[self.params.provider]:
            artifact_path = self.utils.sanitizePath(artifact)
            with open(os.path.join(self.app_path, artifact_path), "r") as fp:
                data = fp.read()

            logger.debug("Templating artifact %s/%s" % (self.app_path, artifact_path))
            data = self._applyTemplate(data, component)
        
            artifact_dst = os.path.join(dst_dir, artifact_path)
            
            if not os.path.isdir(os.path.dirname(artifact_dst)):
                os.makedirs(os.path.dirname(artifact_dst))
            with open(artifact_dst, "w") as fp:
                logger.debug("Writing artifact to %s" % artifact_dst)
                fp.write(data)

#.........這裏部分代碼省略.........
開發者ID:whitel,項目名稱:atomic-app-with-runner,代碼行數:101,代碼來源:run.py


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