Sets the repetition *count* for the stimulus model
168196
def setRepCount(self, count):
        """"""
        self._rep_default_cache[0] = count
        self.ui.trackview.model().setRepCount(count)
208404
def setModel(self, model):
        """"""
        # disconnect old signals
        try:
            self.ui.parametizer.randomizeCkbx.toggled.disconnect()
            self.ui.parametizer.randomizeCkbx.disconnect()
        except TypeError:
            # disconnecting without any current connections throws error
            pass

        self.ui.trackview.setModel(model)
        self.ui.nrepsSpnbx.setValue(model.repCount())

        self.ui.parametizer.randomizeCkbx.toggled.connect(model.randomToggle)
        self.ui.parametizer.randomizeCkbx.setChecked(bool(model.reorder()))

        # extract the QAutoParameterModel from the QStimulusModel and 
        # set in the AutoParameterView
        autoParamModel = model.autoParams()
        self.ui.parametizer.setModel(autoParamModel)
        # whether the auto parameters are emtpy 
        # affects the enable-ness of the StimlusView
        autoParamModel.emptied.connect(self.ui.trackview.emptySelection)
        autoParamModel.countChanged.connect(self.updateTraceCount)
        self.updateTraceCount()
884322
def fill(self):
        ''' '''
        self.frequency2umis = collections.defaultdict(list)

        for read in self.inbam:

            if read.is_unmapped:
                continue

            if read.is_read2:
                continue

            self.umis[self.barcode_getter(read)[0]] += 1

        self.umis_counter = collections.Counter(self.umis)
        total_umis = sum(self.umis_counter.values())
        U.info("total_umis %i" % total_umis)
        U.info("#umis %i" % len(self.umis_counter))

        self.prob = self.umis_counter.values()
        sum_prob = sum(self.prob)
        self.prob = [float(x) / sum_prob for x in self.prob]
        self.refill_random()
1265475
def run(self):
        ''''''
        out = nl.run(self.command_list(),products=self.prefix)
        if out and out.output:
            sds_list = re.findall(r'Stimulus: (.*?) *\n +h\[ 0\] norm\. std\. dev\. = +(\d+\.\d+)',out.output)
            self.stim_sds = {}
            for s in sds_list:
                self.stim_sds[s[0]] = float(s[1])
584765
def p_repeat(self, p):
        ''
        p[0] = Repeat(p[3], p[2], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
553343
def enable_repeat(self, value=None):
        
        if value is None:
            value = not self.repeated
        spotifyconnect.Error.maybe_raise(lib.SpPlaybackEnableRepeat(value))
249506
def frequency_model( self ):
        
        prev_letter = None
        # use a generator in corpus
        prev_letter = list(self.corpus.next_tamil_letter())[0]
        for next_letter in self.corpus.next_tamil_letter():
            # update frequency from corpus
            key = prev_letter+next_letter
            val = self.bigram.get(key,None)
            prev_letter = next_letter
            if not val:
                self.bigram[key] = 0
            self.bigram[key] += 1
        
        return
59786
def repeat(self, repeat):
        """"""
        shuffle = self.shuffle
        self.play_mode = PLAY_MODE_BY_MEANING[(shuffle, repeat)]
1266537
def doExperiment(numObjects,
                 featuresPerObject,
                 objectWidth,
                 numFeatures,
                 featureDistribution,
                 useTrace,
                 noiseFactor,
                 moduleNoiseFactor,
                 numModules,
                 thresholds,
                 inverseReadoutResolution,
                 enlargeModuleFactor,
                 bumpOverlapMethod,
                 seed1,
                 seed2):
  
  if not os.path.exists("traces"):
    os.makedirs("traces")

  if seed1 != -1:
    np.random.seed(seed1)

  if seed2 != -1:
    random.seed(seed2)

  features = [str(i) for i in xrange(numFeatures)]
  objects = generateObjects(numObjects, featuresPerObject, objectWidth,
                            numFeatures, featureDistribution)

  locationConfigs = []
  scale = 40.0

  if thresholds == -1:
    thresholds = int(math.ceil(numModules*0.8))
  elif thresholds == 0:
    thresholds = numModules
  perModRange = float(60.0 / float(numModules))
  for i in xrange(numModules):
    orientation = (float(i) * perModRange) + (perModRange / 2.0)

    locationConfigs.append({
        "scale": scale,
        "orientation": np.radians(orientation),
        "activationThreshold": 8,
        "initialPermanence": 1.0,
        "connectedPermanence": 0.5,
        "learningThreshold": 8,
        "sampleSize": 10,
        "permanenceIncrement": 0.1,
        "permanenceDecrement": 0.0,
        "inverseReadoutResolution": inverseReadoutResolution,
        "enlargeModuleFactor": enlargeModuleFactor,
        "bumpOverlapMethod": bumpOverlapMethod,
    })

  l4Overrides = {
    "initialPermanence": 1.0,
    "activationThreshold": thresholds,
    "reducedBasalThreshold": thresholds,
    "minThreshold": numModules,
    "sampleSize": numModules,
    "cellsPerColumn": 16,
  }

  column = PIUNCorticalColumn(locationConfigs, L4Overrides=l4Overrides,
                              bumpType="gaussian2")
  exp = PIUNExperiment(column, featureNames=features,
                       numActiveMinicolumns=10,
                       noiseFactor=noiseFactor,
                       moduleNoiseFactor=moduleNoiseFactor)

  for objectDescription in objects:
    exp.learnObject(objectDescription)

  convergence = collections.defaultdict(int)
  try:
    if useTrace:
      filename = os.path.join(
        SCRIPT_DIR,
        "traces/{}-resolution-{}-modules-{}-objects-{}-feats.html".format(
          inverseReadoutResolution, numModules, numObjects, numFeatures)
      )
      traceFileOut = io.open(filename, "w", encoding="utf8")
      traceHandle = trace(traceFileOut, exp, includeSynapses=True)
      print "Logging to", filename

    for objectDescription in objects:
      steps = exp.inferObjectWithRandomMovements(objectDescription)
      convergence[steps] += 1
      if steps is None:
        print 'Failed to infer object "{}"'.format(objectDescription["name"])
  finally:
    if useTrace:
      traceHandle.__exit__()
      traceFileOut.close()

  for step, num in sorted(convergence.iteritems()):
    print "{}: {}".format(step, num)

  result = {
    "convergence": convergence,
  }

  return result
427689
function _repeat (source, times) {
    var result = "";

    for (var i = 0; i < times; i++) {
        result += source;
    }

    return result;
}
1362967
def initialize(self, params, repetition):
    
    super(TinyCIFARExperiment, self).initialize(params, repetition)
    self.network_type = params.get("network_type", "sparse")
1090455
public void set(long count, long min, long max, long total, double sumOfSquares,
                    long startTime, long lastSampleTime) {
        this.count = count;
        this.min = min;
        this.max = max;
        this.total = total;
        this.sumOfSquares = sumOfSquares;
        this.startTime = startTime;
        this.lastSampleTime = lastSampleTime;
        // TODO: createTime
    }
595442
def initialize(self, params, repetition):
    
    self.name = params["name"]
    self.dataDir = params.get("datadir", "data")
    self.seed = params.get("seed", 42) + repetition

    torch.manual_seed(self.seed)
    np.random.seed(self.seed)
    random.seed(self.seed)

    # Training
    self.epochs = params.get("epochs", 1)
    self.batch_size = params.get("batch_size", 16)
    self.batches_in_epoch = params.get("batches_in_epoch", 60000)
    self.first_epoch_batch_size = params.get("first_epoch_batch_size", self.batch_size)
    self.batches_in_first_epoch = params.get("batches_in_first_epoch", self.batches_in_epoch)

    # Testing
    self.test_batch_size = params.get("test_batch_size", 1000)

    # Optimizer
    self.optimizer_class = eval(params.get("optimizer", "torch.optim.SGD"))
    self.optimizer_params = eval(params.get("optimizer_params", "{}"))
    self.lr_scheduler_class = eval(params.get("lr_scheduler", None))
    self.lr_scheduler_params = eval(params.get("lr_scheduler_params", "{}"))
    self.loss_function = eval(params.get("loss_function", "torch.nn.functional.nll_loss"))

    # CNN parameters
    c, h, w = map(int, params.get("input_shape", "1_28_28").split("_"))
    self.in_channels = c
    self.out_channels = map(int, params.get("out_channels", "30_30").split("_"))
    self.kernel_size = map(int, params.get("kernel_size", "5_5").split("_"))
    self.stride = map(int, params.get("stride", "1_1").split("_"))
    self.padding = map(int, params.get("padding", "0_0").split("_"))

    # Compute Flatten CNN output len
    self.maxpool = []
    self.maxpool.append(
      ((w + 2 * self.padding[0] - self.kernel_size[0]) // self.stride[0] + 1) // 2)
    self.maxpool.append(
      ((self.maxpool[0] + 2 * self.padding[1] - self.kernel_size[1]) // self.stride[1] + 1) // 2)

    self.cnn_output_len = [self.maxpool[i] * self.maxpool[i] * self.out_channels[i]
                           for i in range(len(self.maxpool))]

    # Linear parameteers
    self.n = params.get("n", 1000)
    self.output_size = params.get("output_size", 10)

    # Sparse parameters
    if "c1_k" in params:
      self.cnn_k = map(int, params["c1_k"].split("_"))
    else:
      self.cnn_k = self.cnn_output_len

    self.k = params.get("k", self.n)
    self.k_inference_factor = params.get("k_inference_factor", 1.0)
    self.boost_strength = params.get("boost_strength", 1.0)
    self.boost_strength_factor = params.get("boost_strength_factor", 1.0)
    self.weight_sparsity = params.get("weight_sparsity", 1.0)
    self.weight_sparsity_cnn = params.get("weight_sparsity_cnn", 1.0)
716512
def set_initial_representations(self):
        """"""
        self.update_model_dict()
        self.rc("background solid white")
        self.rc("setattr g display 0")  # Hide all pseudobonds
        self.rc("~display #%i & :/isHet & ~:%s" % (self.model_dict[self.plipname], self.hetid))
799339
def array_repeat(col, count):
    
    sc = SparkContext._active_spark_context
    return Column(sc._jvm.functions.array_repeat(_to_java_column(col), count))
1244404
def update(self, mini_batch, num_sequences):
        

        feed_dict = {self.model.dropout_rate: self.update_rate,
                     self.model.batch_size: num_sequences,
                     self.model.sequence_length: self.sequence_length}
        if self.use_continuous_act:
            feed_dict[self.model.true_action] = mini_batch['actions']. \
                reshape([-1, self.brain.vector_action_space_size[0]])
        else:
            feed_dict[self.model.true_action] = mini_batch['actions'].reshape(
                [-1, len(self.brain.vector_action_space_size)])
            feed_dict[self.model.action_masks] = np.ones(
                (num_sequences, sum(self.brain.vector_action_space_size)))
        if self.use_vec_obs:
            apparent_obs_size = self.brain.vector_observation_space_size * \
                                self.brain.num_stacked_vector_observations
            feed_dict[self.model.vector_in] = mini_batch['vector_obs'] \
                .reshape([-1,apparent_obs_size])
        for i, _ in enumerate(self.model.visual_in):
            visual_obs = mini_batch['visual_obs%d' % i]
            feed_dict[self.model.visual_in[i]] = visual_obs
        if self.use_recurrent:
            feed_dict[self.model.memory_in] = np.zeros([num_sequences, self.m_size])
        run_out = self._execute_model(feed_dict, self.update_dict)
        return run_out
274440
def setEditor(self, name):
        """"""
        editor = get_stimulus_editor(name)
        self.editor = editor
        self._stim.setStimType(name)