Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(8)  |  Call(7)  |  Derive(0)  |  Import(1)

src/d/r/dragnet-HEAD/dragnet/data_processing.py   dragnet(Download)
    def _diagnose_data_one_source(self, plotdir, ti, training_or_test='both'):
        """Make some plots and do some exploratory analyis on training data
        training_or_test is one of "training", "test", "both"
        """
        from mozsci.histogram import Histogram1DFast
 
                # count of extracted blocks in each bin
                h = Histogram1DFast(bins, 0, 1)
                h.update_counts(block_percent, extracted_flag)
                extracted_counts = h.bin_count
 
                # overall count
                h = Histogram1DFast(bins, 0, 1)
                # number of tokens in block
                if c == 'content':  # token count same for content, comments
                    h = Histogram1DFast(bins, 0, 1)
                    h.update_counts(block_percent, overall_token_count)
                    token_count = h.bin_count

src/m/o/mozsci-HEAD/test/test_histogram.py   mozsci(Download)
    def test_histogram1d(self):
 
        h = histogram.Histogram1DFast(10, 0, 10)
        self.assertTrue((np.abs(h.bin_edges - np.arange(11)) < 1.0e-12).all())
 
        x = np.random.randn(1e7)
        time1 = time.time()
        h = histogram.Histogram1DFast(100, -5, 5)
        h.update(x)
        time2 = time.time()
    def test_stratified_sample(self):
        hist = histogram.Histogram1DFast(5, 0, 5)
        hist.update_counts(np.array([0.5, 1.5, 2.5, 3.5, 4.5]),
                           np.array([5e6, 1e6, 1e4, 1e3, 2]))
 
        sample_size = [500, 300, 100, 98, 2]
        x_stratified_sample = hist.stratified_sample(x, sample_size)
        hist_check = histogram.Histogram1DFast(5, 0, 5)
        hist_check.update(x_stratified_sample)