Ejemplo n.º 1
0
 def test_hist_index_min_max(self):
     "Test min_out and max_out on HistogramIndex"
     s = self.scheduler()
     random = RandomTable(2, rows=100000, scheduler=s)
     t_min = Table(name=None, dshape='{_1: float64}', data={'_1': [0.3]})
     min_value = Constant(table=t_min, scheduler=s)
     t_max = Table(name=None, dshape='{_1: float64}', data={'_1': [0.8]})
     max_value = Constant(table=t_max, scheduler=s)
     range_qry = RangeQuery(column='_1', scheduler=s)
     range_qry.create_dependent_modules(random,
                                        'table',
                                        min_value=min_value,
                                        max_value=max_value)
     prt = Print(proc=self.terse, scheduler=s)
     prt.input.df = range_qry.output.table
     hist_index = range_qry.hist_index
     min_ = Min(name='min_' + str(hash(hist_index)), scheduler=s)
     min_.input.table = hist_index.output.min_out
     prt2 = Print(proc=self.terse, scheduler=s)
     prt2.input.df = min_.output.table
     max_ = Max(name='max_' + str(hash(hist_index)), scheduler=s)
     max_.input.table = hist_index.output.max_out
     pr3 = Print(proc=self.terse, scheduler=s)
     pr3.input.df = max_.output.table
     s.start()
     s.join()
     res1 = random.table().min()['_1']
     res2 = min_.table().last().to_dict()['_1']
     self.assertAlmostEqual(res1, res2)
     res1 = random.table().max()['_1']
     res2 = max_.table().last().to_dict()['_1']
     self.assertAlmostEqual(res1, res2)
Ejemplo n.º 2
0
 def test_min(self):
     s = self.scheduler()
     random = RandomTable(10, rows=10000, scheduler=s)
     min_ = Min(name='min_' + str(hash(random)), scheduler=s)
     min_.input.table = random.output.table
     pr = Print(proc=self.terse, scheduler=s)
     pr.input.df = min_.output.table
     s.start()
     s.join()
     res1 = random.table().min()
     res2 = min_.table().last()
     self.compare(res1, res2)
Ejemplo n.º 3
0
 def test_idxmin(self):
     s = self.scheduler()
     random = RandomTable(10, rows=10000, throttle=1000, scheduler=s)
     idxmin = IdxMin(scheduler=s)
     idxmin.input.table = random.output.table
     min_ = Min(scheduler=s)
     min_.input.table = random.output.table
     pr = Print(proc=self.terse, scheduler=s)
     pr.input.df = idxmin.output.min
     s.start()
     s.join()
     min1 = min_.table().last().to_dict()
     #print('min1', min1)
     min2 = idxmin.min().last().to_dict()
     #print('min2', min2)
     self.assertAlmostEqual(min1, min2)