Populates objects with the necessary attributes
        :param sample: sample object
542912
def populator(self, sample):
        
        from accessoryFunctions.accessoryFunctions import GenObject
        if sample.general.bestassemblyfile != 'NA':
            profile = ''
            setattr(sample, self.analysistype, GenObject())
            sample[self.analysistype].analyse = True
            if self.analysistype.lower() == 'rmlst':
                # Run the allele updater method
                updatecall, allelefolder = getrmlsthelper(self.referencefilepath, self.updatedatabases, self.start)
                # Alleles have a .tfa extension
                self.alleles = glob('{}/*.tfa'.format(allelefolder))
                # Get the profile file into a list
                profile = glob('{}/*.txt'.format(allelefolder))
                self.supplementalprofile = '{}rMLST/OLC_rMLST_profiles.txt'.format(self.referencefilepath)
                self.supplementalalleles = '{}rMLST/OLC_rMLST_alleles.fa'.format(self.referencefilepath)
                self.combinedalleles = glob('{}/*.fasta'.format(allelefolder))
                # Set the metadata file appropriately
                sample[self.analysistype].alleledir = allelefolder
                sample[self.analysistype].updatecall = updatecall
            else:
                # Use the getmlsthelper module to download databases as required
                schemefolder = getmlsthelper(self.referencefilepath, self.start, sample.general.referencegenus,
                                             self.updatedatabases)
                # If there is no database folder, do not perform the MLST analyses on this sample
                if not schemefolder:
                    sample[self.analysistype].analyse = False
                    # Set the metadata file appropriately
                    sample[self.analysistype].alleles = 'NA'
                    sample[self.analysistype].allelenames = 'NA'
                    sample[self.analysistype].profile = 'NA'
                    sample[self.analysistype].analysistype = 'NA'
                    sample[self.analysistype].reportdir = 'NA'
                    sample[self.analysistype].combinedalleles = 'NA'
                    sample[self.analysistype].supplementalprofile = 'NA'
                    sample[self.analysistype].supplementalalleles = 'NA'
                    sample[self.analysistype].alleledir = 'NA'
                else:
                    self.alleles = glob('{}/*.tfa'.format(schemefolder))
                    profile = glob('{}/*.txt'.format(schemefolder))
                    self.combinedalleles = glob('{}/*.fasta'.format(schemefolder))
                    sample[self.analysistype].alleledir = schemefolder
            # Only perform analyses on samples with target databases
            if sample[self.analysistype].analyse:
                sample[self.analysistype].alleles = self.alleles
                sample[self.analysistype].allelenames = [os.path.split(x)[1].split('.')[0] for x in self.alleles]
                sample[self.analysistype].profile = profile if profile else 'NA'
                sample[self.analysistype].analysistype = self.analysistype
                sample[self.analysistype].reportdir = '{}/{}/'.format(sample.general.outputdirectory,
                                                                      self.analysistype)
                sample[self.analysistype].combinedalleles = self.combinedalleles
                sample[self.analysistype].supplementalprofile = self.supplementalprofile \
                    if self.supplementalprofile else 'NA'
                sample[self.analysistype].supplementalalleles = self.supplementalalleles \
                    if self.supplementalalleles else 'NA'
                print(sample[self.analysistype].datastore)

        else:
            setattr(sample, self.analysistype, GenObject())
            # Set the metadata file appropriately
            sample[self.analysistype].alleledir = 'NA'
            sample[self.analysistype].alleles = 'NA'
            sample[self.analysistype].allelenames = 'NA'
            sample[self.analysistype].profile = 'NA'
            sample[self.analysistype].analysistype = 'NA'
            sample[self.analysistype].reportdir = 'NA'
            sample[self.analysistype].combinedalleles = 'NA'
            sample[self.analysistype].supplementalprofile = 'NA'
            sample[self.analysistype].supplementalalleles = 'NA'
835894
def sample(self, nsamples=100, seed=None):
        
        if nsamples < 1:
            raise ValueError("Number of samples must be larger than 0, got '%g'" % nsamples)

        if seed is None:
            seed = random.randint(0, 2 ** 32)

        if self.mode == 'spark':
            result = asarray(self.values.tordd().values().takeSample(False, nsamples, seed))

        else:
            inds = [int(k) for k in random.rand(nsamples) * self.shape[0]]
            result = asarray([self.values[i] for i in inds])

        return self._constructor(result)
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)
1111737
def _get_sampleset(model):
    """"""
    if isinstance(model, Model):
        if hasattr(model, 'sampleset'):
            w = model.sampleset()
        else:
            w = None
    else:
        w = model  # Already a sampleset
    return w
651904
def from_dict(cls, raw_data, **kwargs):
        
        instance = cls()
        instance.populate(raw_data, **kwargs)
        instance.validate(**kwargs)
        return instance
1337845
def add_sample(self, **data):
        """"""
        missing_dimensions = set(data).difference(self.dimensions)

        if missing_dimensions:
            raise KeyError('Dimensions not defined in this series: %s'
                           % ', '.join(missing_dimensions))

        for dim in self.dimensions:
            getattr(self, dim).append(data.get(dim))
54603
def add_sample(self, value, timestamp, attachments):
        """"""
        self._count_data += 1
        bucket = self.increment_bucket_count(value)

        if attachments is not None and self.exemplars is not None:
            self.exemplars[bucket] = Exemplar(value, timestamp, attachments)
        if self.count_data == 1:
            self._mean_data = value
            return

        old_mean = self._mean_data
        self._mean_data = self._mean_data + (
            (value - self._mean_data) / self._count_data)
        self._sum_of_sqd_deviations = self._sum_of_sqd_deviations + (
            (value - old_mean) * (value - self._mean_data))
1047472
def initialize(self, data):
        
        for item in data:
            if hasattr(self, item):
                setattr(self, item, data[item])
919341
def populate_model(model_or_inst, excludes=None, only=None):
    
    inst = model_or_inst if _is_inst(model_or_inst) else model_or_inst()

    parser = make_request_parser(model_or_inst, excludes, only, for_populate=True)
    req_args = parser.parse_args()

    for key, value in req_args.items():
        setattr(inst, key, value)

    return inst
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
1023486
def _prepare_sample(data, run_folder):
    
    want = set(["description", "files", "genome_build", "name", "analysis", "upload", "algorithm"])
    out = {}
    for k, v in data.items():
        if k in want:
            out[k] = _relative_paths(v, run_folder)
    if "algorithm" not in out:
        analysis, algorithm = _select_default_algorithm(out.get("analysis"))
        out["algorithm"] = algorithm
        out["analysis"] = analysis
    description = "%s-%s" % (out["name"], clean_name(out["description"]))
    out["name"] = [out["name"], description]
    out["description"] = description
    return out
1145275
def populateFromRow(self, ontologyRecord):
        
        self._id = ontologyRecord.id
        self._dataUrl = ontologyRecord.dataurl
        self._readFile()
915480
def _preallocate_samples(self):
        
        self.prealloc_samples_ = []
        for i in range(self.num_prealloc_samples_):
            self.prealloc_samples_.append(self.sample())
28980
def prepopulate(self, queryset):
        
        objs = list(queryset)
        hashobjs = dict([(x.pk, x) for x in objs] + [(self.pk, self)])
        for descendant in hashobjs.values():
            descendant._cached_children = []
        for descendant in objs:
            assert descendant._closure_parent_pk in hashobjs
            parent = hashobjs[descendant._closure_parent_pk]
            parent._cached_children.append(descendant)
1116064
def _sample_data(self, sample):
        
        data = {}
        if sample:
            data = {'obj': sample,
                    'id': sample.id,
                    'url': sample.absolute_url(),
                    'date_sampled': self.ulocalized_time(
                        sample.getDateSampled(), long_format=True),
                    'date_received': self.ulocalized_time(
                        sample.getDateReceived(), long_format=0),
                    }

            if sample.portal_type == "ReferenceSample":
                data['sample_type'] = None
                data['sample_point'] = None
            else:
                data['sample_type'] = self._sample_type(sample)
                data['sample_point'] = self._sample_point(sample)
        return data
954150
def _sample_type(self, sample=None):
        
        data = {}
        sampletype = sample.getSampleType() if sample else None
        if sampletype:
            data = {'obj': sampletype,
                    'id': sampletype.id,
                    'title': sampletype.Title(),
                    'url': sampletype.absolute_url()}
        return data
1017446
public SimpleDataSet generateData(int samples)
    {
        int totalClasses = 1;
        for(int d : dimensions)
            totalClasses *= d;
        catDataInfo = new CategoricalData[] { new CategoricalData(totalClasses) } ;
        List<DataPoint> dataPoints = new ArrayList<DataPoint>(totalClasses*samples);
        int[] curClassPointer = new int[1];
                
        for(int i = 0; i < dimensions[0]; i++)
        {
            int[] curDim = new int[dimensions.length];
            curDim[0] = i;
            addSamples(curClassPointer, 0, samples, dataPoints, curDim);
        }
        
        return new SimpleDataSet(dataPoints);
    }