Function to add the counts for each sample

        :param gr: name of the sample
        :param exp: counts of sample **gr**

        :returns: dict with key,values equally to name,counts.
420564
def add_exp(self,gr,exp):
        
        self.group[gr] = exp
        self.total = sum(self.group.values())
1041515
def _insert(self, key, records, count):
        
        if key not in self.records:
            assert key not in self.counts
            self.records[key] = records
            self.counts[key] = count
        else:
            self.records[key] = np.vstack((self.records[key], records))
            assert key in self.counts
            self.counts[key] += count
46872
def value_counts(arg, metric_name='count'):
    
    base = ir.find_base_table(arg)
    metric = base.count().name(metric_name)

    try:
        arg.get_name()
    except com.ExpressionError:
        arg = arg.name('unnamed')

    return base.group_by(arg).aggregate(metric)
490763
def add_samples(self, samples: Iterable[Sample]) -> None:
        """"""
        for sample in samples:
            self.add_sample(sample)
921284
def sample(self, num_rows):
        

        sampled_values = []
        for i in range(num_rows):
            sampled_values.append(self._sample_row())

        return pd.DataFrame(sampled_values, columns=self.columns)
1299870
def expand_counts(df, column, values=None):
    
    d = counts_to_dicts(df, column)
    if len(d) > 0:
        if values is None:
            values = set(np.concatenate(d.apply(lambda c: c.keys()).values))
        for value in values:
            name = values[value] if type(values) is dict else str(value)
            df[column + '_' + name.replace(' ', '_')] =\
                d.apply(lambda c: c[value] if value in c else 0)
    df.drop(column, axis=1, inplace=True)
809178
def make_count_grid(data):
    
    data = deepcopy(data)

    for i in range(len(data)):
        for j in range(len(data[i])):
            for k in range(len(data[i][j])):
                if type(data[i][j][k]) is list:
                    for l in range(len(data[i][j][k])):
                        try:
                            data[i][j][k] = data[i][j][k][l].count("1")
                        except:
                            data[i][j][k] = len(data[i][j][k][l])
                else:
                    try:
                        data[i][j][k] = data[i][j][k].count("1")
                    except:
                        data[i][j][k] = len(data[i][j][k])

    return data
711604
def _init_count_terms(self, annots):
        '''
            
        '''
        gonotindag = set()
        gocnts = self.gocnts
        go2obj = self.go2obj
        # Fill gocnts with GO IDs in annotations and their corresponding counts
        for terms in annots.values(): # key is 'gene'
            # Make a union of all the terms for a gene, if term parents are
            # propagated but they won't get double-counted for the gene
            allterms = set()
            for go_id in terms:
                goobj = go2obj.get(go_id, None)
                if goobj is not None:
                    allterms.add(go_id)
                    allterms |= goobj.get_all_parents()
                else:
                    gonotindag.add(go_id)
            for parent in allterms:
                gocnts[parent] += 1
        if gonotindag:
            print("{N} Assc. GO IDs not found in the GODag\n".format(N=len(gonotindag)))
1050616
def add_sample(self, name, labels, value, timestamp=None, exemplar=None):
        """"""
        self.samples.append(Sample(name, labels, value, timestamp, exemplar))
579565
def _record(self, value, rank, delta, successor):
        """"""
        self._observations += 1
        self._items += 1

        return _Sample(value, rank, delta, successor)
1172483
def analyzeParameters(expName, suite):
  
  print("\n================",expName,"=====================")
  try:
    expParams = suite.get_params(expName)
    pprint.pprint(expParams)

    for p in ["boost_strength", "k", "learning_rate", "weight_sparsity",
              "k_inference_factor", "boost_strength_factor",
              "c1_out_channels", "c1_k", "learning_rate_factor",
              "batches_in_epoch",
              ]:
      if p in expParams and type(expParams[p]) == list:
        print("\n",p)
        for v1 in expParams[p]:
          # Retrieve the last totalCorrect from each experiment
          # Print them sorted from best to worst
          values, params = suite.get_values_fix_params(
            expName, 0, "testerror", "last", **{p:v1})
          v = np.array(values)
          try:
            print("Average/min/max for", p, v1, "=", v.mean(), v.min(), v.max())
            # sortedIndices = v.argsort()
            # for i in sortedIndices[::-1]:
            #   print(v[i],params[i]["name"])
          except:
            print("Can't compute stats for",p)

  except:
    print("Couldn't load experiment",expName)
983805
def _sampler_n_samples(self, n_samples):
        
        sampler_indices = self.rng_.choice(range(len(self.samplers)),
                                           size=n_samples,
                                           replace=True,
                                           p=self.weights)
        return [
            (self.samplers[idx], freq)
            for idx, freq in itemfreq(sampler_indices)
        ]
383895
def samples(self, gp, Y_metadata=None):
        
        orig_shape = gp.shape
        gp = gp.flatten()
        #FIXME: Very slow as we are computing a new random variable per input!
        #Can't get it to sample all at the same time
        #student_t_samples = np.array([stats.t.rvs(self.v, self.gp_link.transf(gpj),scale=np.sqrt(self.sigma2), size=1) for gpj in gp])
        dfs = np.ones_like(gp)*self.v
        scales = np.ones_like(gp)*np.sqrt(self.sigma2)
        student_t_samples = stats.t.rvs(dfs, loc=self.gp_link.transf(gp),
                                        scale=scales)
        return student_t_samples.reshape(orig_shape)
763641
def get_samples(self, sample_count):
        
        if self.amplitude.value <= 0:
            return None
        # Build samples by rolling the period cache through the buffer
        rolled_array = numpy.roll(self.wave_cache,
                                  -1 * self.last_played_sample)
        # Append remaining partial period
        full_count, remainder = divmod(sample_count, self.cache_length)
        final_subarray = rolled_array[:int(remainder)]
        return_array = numpy.concatenate((numpy.tile(rolled_array, full_count),
                                          final_subarray))
        # Keep track of where we left off to prevent popping between chunks
        self.last_played_sample = int(((self.last_played_sample + remainder) %
                                       self.cache_length))
        # Multiply output by amplitude
        return return_array * (self.amplitude.value *
                               self.amplitude_multiplier)
1265862
def get_samples(self, init_points_count):
        

        init_points_count = self._adjust_init_points_count(init_points_count)
        samples = np.empty((init_points_count, self.space.dimensionality))

        # Use random design to fill non-continuous variables
        random_design = RandomDesign(self.space)
        random_design.fill_noncontinous_variables(samples)

        if self.space.has_continuous():
            X_design = multigrid(self.space.get_continuous_bounds(), self.data_per_dimension)
            samples[:,self.space.get_continuous_dims()] = X_design

        return samples
726132
def stats(self, name, value):
        
        counter = self.get(name, CounterType.Statistics)
        self._calculate_stats(counter, value)
        self._update()
948341
def compute_rarity_scores_log(exemplars):
    
    scores = defaultdict(lambda: 0.)
    for followers in exemplars.values():
        score = 1. / math.log(len(followers))
        for f in followers:
            scores[f] += score
    return scores