Пример #1
0
    def _ast_impl(self):
        args = [ast.Raw(self.numerator), ast.Raw(self.denominator)]

        if self.cap_below:
            args += [(ast.Name('min'), ast.Constant(self.cap_below_at))]
            if self.cap_below_at != self.cap_below_with:
                args += [(ast.Name('min_to'),
                          ast.Constant(self.cap_below_with))]
        if self.cap_above:
            args += [(ast.Name('max'), ast.Constant(self.cap_above_at))]
            if self.cap_above_at != self.cap_above_with:
                args += [(ast.Name('max_to'),
                          ast.Constant(self.cap_above_with))]

        if self.replace_zero:
            args += [(ast.Name('zero_to'),
                      ast.Constant(self.replace_zero_with))]
        if self.replace_inf:
            args += [(ast.Name('inf_to'), ast.Constant(self.replace_inf_with))]
        if self.replace_na:
            args += [(ast.Name('na_to'), ast.Constant(self.replace_na_with))]

        node = ast.Call(ast.Name('ratio'), args)
        if self.log_transform:
            node = ast.Call(ast.Name('safe_log1p'), node)
        return node
Пример #2
0
 def ast(self):
     return ast.Call(ast.Name('def_group_metric'),
                     ast.Constant(self.name),
                     ast.Raw(self.expression),
                     ast.Name('entropy_disc'),
                     (ast.Name('type'), ast.Constant(self.method)),
                     print_hint='long')
Пример #3
0
 def ast(self):
     R_funcs = {
         'chi_square': 'chisq_test',
         'ks': 'ks.stat',
         'custom': self.custom_function,
     }
     return ast.Call(ast.Name('def_group_metric'),
                     ast.Constant(self.name),
                     ast.Raw(self.expression),
                     ast.Name(R_funcs[self.kind]),
                     print_hint='long')
Пример #4
0
 def _ast_impl(self):
     args = [ast.Raw(self.expression)]
     if self.auto_breaks:
         arg_breaks = ast.Constant(self.num_breaks)
     else:
         arg_breaks = ast_macros.seq_to_vector(self.breaks)
     args.append((ast.Name('breaks'), arg_breaks))
     if self.labels:
         args.append(
             (ast.Name('labels'), ast_macros.seq_to_vector(self.labels)))
     if self.closed_on_left:
         # By default, R closes on the right.
         args.append((ast.Name('right'), ast.Constant(False)))
     return ast.Call(ast.Name('cut'), args, print_hint='long')
Пример #5
0
 def _ast_impl(self):
     return ast.Raw(self.expression)
Пример #6
0
 def ast(self):
     return ast.Call(ast.Name('def_group_metric'),
                     ast.Constant(self.name),
                     ast.Raw(self.expression),
                     ast.Name('graph_density'),
                     print_hint='long')
Пример #7
0
 def ast(self):
     return ast.Call(ast.Name('def_group_metric'),
                     ast.Constant(self.name),
                     ast.Raw(self.expression),
                     ast.Name('uniq_cont'),
                     print_hint='long')