Generate a Calc object for each requested parameter combination.
5698
def create_calcs(self):
        """"""
        specs = self._combine_core_aux_specs()
        for spec in specs:
            spec['dtype_out_time'] = _prune_invalid_time_reductions(spec)
        return [Calc(**sp) for sp in specs]
1125509
def params(self):
        """"""
        comb_sizes = []
        comb_keys = []
        for key,val in self.comb_params.items():
            comb_keys.append(key)
            comb_sizes.append(len(val))
        # length of first values array, since lengths should match for sets of
        # jointly varying parameters
        joint_sizes = [len(next(iter(jlist.values()))) for jlist in self.joint_params]
        all_sizes = comb_sizes + joint_sizes
        total_combinations = reduce(operator.mul, all_sizes, 1)
        for i in range(total_combinations):
            sub = np.unravel_index(i, all_sizes)
            params = {}
            # get the comb_params
            for j in range(len(comb_sizes)):
                key = comb_keys[j]
                val_arr = self.comb_params[key]
                params[key] = val_arr[sub[j]]
            # get the joint_params
            for j in range(len(joint_sizes)):
                subj = j + len(comb_sizes)
                for key,val_arr in self.joint_params[j].items():
                    params[key] = val_arr[sub[subj]]
            # how we have one parameter set, check how many times to repeat it
            num_repeats = self.default_repeats
            for func in self.count_funcs:
                c = func(params)
                if c:
                    num_repeats = c
            for i in range(num_repeats):
                yield params
528753
def params(self):
        """"""
        ret = {}
        for rd in self.decorators:
            args = rd.args
            kwargs = rd.kwargs
            if param in rd:
                is_required =  kwargs.get('required', 'default' not in kwargs)
                ret[args[0]] = {'required': is_required, 'other_names': args[1:], 'options': kwargs}

        return ret
1086506
function Calculator(settings) {
    this.settings = assign({}, defaults, settings);
    this.requests = new Requests(this.settings['apiUrl'], this.settings['version'], this.settings['publicKey']);
}
1081696
def pufunc(func):
    
    def dtrm_generator(*args):
        if len(args) != func.nin:
            raise ValueError('invalid number of arguments')
        name = func.__name__ + '(' + '_'.join(
            [str(arg) for arg in list(args)]) + ')'
        doc_str = 'A deterministic returning %s(%s)' % (
            func.__name__,
            ', '.join([str(arg) for arg in args]))
        parents = {}
        for i in xrange(func.nin):
            parents['in%i' % i] = args[i]

        def wrapper(**kwargs):
            return func(*[kwargs['in%i' % i] for i in xrange(func.nin)])
        return pm.Deterministic(
            wrapper, doc_str, name, parents, trace=False, plot=False)
    dtrm_generator.__name__ = func.__name__ + '_deterministic_generator'
    dtrm_generator.__doc__ = """
Deterministic-generating wrapper for %s. Original docstring:
%s

%s
    """ % (func.__name__, '_' * 60, func.__doc__)
    return dtrm_generator
1108878
def calc(self, *args, **kwargs):
        
        cases = kwargs.pop('_cases', [])
        if not isinstance(cases, Iterable):
            cases = [cases, ]
        result_callback = kwargs.pop('_result_callback', None)
        execute_now = kwargs.pop('execute_now', True)

        exec_id = self._get_exec_id()
        params = dict((k, v.value) for k, v in six.iteritems(self._parameters))

        obj_dict = self._map_inputs_from_args(*args, **kwargs)
        engine_kw = dict(p for p in six.iteritems(kwargs) if p[0] not in obj_dict)

        expr_kw = dict(_params=params, _exec_id=exec_id, _engine_kw=engine_kw)
        if cases:
            expr_kw['_cases'] = cases

        expr_kw.update((ML_ARG_PREFIX + k, v) for k, v in six.iteritems(obj_dict))
        if result_callback:
            expr_kw['_result_callback'] = result_callback
        expr = self._metrics_expr(**expr_kw)

        if execute_now:
            return expr.execute()
        else:
            return expr
950747
def _compile_int(self):
        """"""
        string = '"""\n'

        # evaluate the algebraic equations g
        string += 'system.dae.init_fg(resetz=False)\n'
        for gcall, call in zip(self.gcall, self.gcalls):
            if gcall:
                string += call
        string += '\n'
        string += 'system.dae.reset_small_g()\n'

        # handle islands
        string += self.gisland

        # evaluate differential equations f
        for fcall, call in zip(self.fcall, self.fcalls):
            if fcall:
                string += call
        string += 'system.dae.reset_small_f()\n'
        string += '\n'

        fg_string = string + '"""'
        self.int_fg = compile(eval(fg_string), '', 'exec')

        # rebuild constant Jacobian elements if needed
        string += 'if system.dae.factorize:\n'
        string += '    system.dae.init_jac0()\n'
        for jac0, call in zip(self.jac0, self.jac0s):
            if jac0:
                string += '    ' + call
        string += '    system.dae.temp_to_spmatrix(\'jac0\')\n'

        # evaluate Jacobians Gy and Fx
        string += 'system.dae.setup_FxGy()\n'
        for gycall, call in zip(self.gycall, self.gycalls):
            if gycall:
                string += call
        string += '\n'
        for fxcall, call in zip(self.fxcall, self.fxcalls):
            if fxcall:
                string += call
        string += self.gyisland
        string += 'system.dae.temp_to_spmatrix(\'jac\')\n'

        string += '"""'
        if SHOW_INT_CALL:
            logger.debug(string)

        self.int = compile(eval(string), '', 'exec')
739930
def defvars(self):
    """"""
    for f in self.body:
        if (hasattr(f, '_ctype')
                and f._name != ''
                and not isinstance(f._ctype, FuncType)
                and f._ctype._storage != Storages.TYPEDEF):
            yield f
618815
def computed_fitting_parameters(self):
        
        fitted_parameters = []
        for (i, v) in enumerate(self.fitting_parameters):
            param = v.copy()
            param['value'] = self.fitted_parameters[i] * prefix_factor(param)**(-1)
            fitted_parameters.append(param)

        return fitted_parameters
124024
def _generate_constructor(cls, names):
        """"""

        cache = cls._constructors
        if names in cache:
            return cache[names]
        elif len(cache) > 3:
            cache.clear()

        func = generate_constructor(cls, names)
        cache[names] = func
        return func
1035720
def construct_parameter_pattern(parameter):
    
    name = parameter['name']
    type = parameter['type']

    repeated = '[^/]'

    if type == 'integer':
        repeated = '\d'

    return "(?P<{name}>{repeated}+)".format(name=name, repeated=repeated)
810564
def parameters(self, value):
        """"""
        self.W = value[0] if isinstance(value[0], GPUArray) else \
          gpuarray.to_gpu(value[0])
        self.b = value[1] if isinstance(value[0], GPUArray) else \
          gpuarray.to_gpu(value[1])
1009700
def _calc_keys(self, config, name, timestamp):
    '''
    
    '''
    i_bucket = config['i_calc'].to_bucket( timestamp )
    r_bucket = config['r_calc'].to_bucket( timestamp )

    i_key = '%s%s:%s:%s'%(self._prefix, name, config['interval'], i_bucket)
    r_key = '%s:%s'%(i_key, r_bucket)

    return i_bucket, r_bucket, i_key, r_key
1132580
def _parametersAsIndex( self, ps ):
        """"""
        k = ""
        for p in sorted(ps.keys()):       # normalise the parameters
            v = ps[p]
            k = k + "{p}=[[{v}]];".format(p = p, v = v)
        return k
168700
def createExperimentArgs():
  """"""
  experimentArguments = []
  # for n in [300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900, 2100, 2300,
  #           2500, 2700, 2900, 3100, 3300, 3500, 3700, 3900]:
  for n in [1500, 1700, 1900, 2100]:
    for a in [128]:
      # Some parameter combinations are just not worth running!
      if ( a==64 and n<=1500 ) or ( a==128 and n<= 1900 ) or ( a==256 ):
        experimentArguments.append(
          ("./sdr_calculations2", "results_errorbars/temp_"+str(n)+"_"+str(a)+".csv",
           "200000", str(n), str(a), "0"),
        )
  return experimentArguments
1353280
def generate(self):
        """"""

        ts=self.generate_tobs()
        noise=self.generate_noise(ts)
        
        rvs=[]
        for t,n in zip(ts, noise):
            rvs.append(n + np.sum(rv.rv_model(t, self.params), axis=0))

        return ts,rvs
202807
def make_parameter_dict(pdict, fixed_par=False, rescale=True,
                        update_bounds=False):
    
    o = copy.deepcopy(pdict)
    o.setdefault('scale', 1.0)

    if rescale:
        value, scale = utils.scale_parameter(o['value'] * o['scale'])
        o['value'] = np.abs(value) * np.sign(o['value'])
        o['scale'] = np.abs(scale) * np.sign(o['scale'])
        if 'error' in o:
            o['error'] /= np.abs(scale)

    if update_bounds:
        o['min'] = o['value'] * 1E-3
        o['max'] = o['value'] * 1E3

    if fixed_par:
        o['min'] = o['value']
        o['max'] = o['value']

    if float(o['min']) > float(o['value']):
        o['min'] = o['value']

    if float(o['max']) < float(o['value']):
        o['max'] = o['value']

    return o