Пример #1
0
    def code_line(self, var_name: str, unnamed_input_vars: Sequence[str],
                  named_input_vars: Dict[str, str]) -> str:
        if self.operation in BINARY_OPERATIONS:
            assert len(
                named_input_vars
            ) == 0, 'Named parameters can not be used with binary operations'
            assert len(
                unnamed_input_vars
            ) == 2, 'Binary Operations need exactly two input variables'
            return f'{var_name}={unnamed_input_vars[0]}{self.operation}{unnamed_input_vars[1]}'

        inputs_comma_sep = create_params_string(unnamed_input_vars,
                                                named_input_vars)

        if self.output_type == OutputType.LIST:
            output = "["
            for idx in range(self._number_of_outputs):
                output += f'{var_name}_{idx},'
            output = output[:-1] + "]"
            return f'{output}={self.operation}({inputs_comma_sep});'
        elif self.output_type == OutputType.NONE:
            return f'{self.operation}({inputs_comma_sep});'
        elif self.output_type == OutputType.ASSIGN:
            return f'{var_name}={self.operation};'
        else:
            return f'{var_name}={self.operation}({inputs_comma_sep});'
Пример #2
0
 def code_line(self, var_name: str, unnamed_input_vars: Sequence[str],
               named_input_vars: Dict[str, str]) -> str:
     if self.operation in BINARY_OPERATIONS:
         assert len(named_input_vars) == 0, 'Named parameters can not be used with binary operations'
         assert len(unnamed_input_vars) == 2, 'Binary Operations need exactly two input variables'
         return f'{var_name}={unnamed_input_vars[0]}{self.operation}{unnamed_input_vars[1]}'
     else:
         inputs_comma_sep = create_params_string(unnamed_input_vars, named_input_vars)
         return f'{var_name}={self.operation}({inputs_comma_sep});'
Пример #3
0
    def code_line(self, var_name: str, unnamed_input_vars: Sequence[str],
                  named_input_vars: Dict[str, str]) -> str:

        inputs_comma_sep = create_params_string(unnamed_input_vars,
                                                named_input_vars)
        output = "["
        for idx, output_node in enumerate(self._outputs):
            name = f'{var_name}_{idx}'
            output_node.dml_name = name
            output += f'{name},'

        output = output[:-1] + "]"

        return f'{output}={self.operation}({inputs_comma_sep});'
Пример #4
0
 def code_line(self, var_name: str, unnamed_input_vars: Sequence[str],
               named_input_vars: Dict[str, str]) -> str:
     inputs_comma_sep = create_params_string(unnamed_input_vars,
                                             named_input_vars)
     return f'{var_name}={self.operation}({inputs_comma_sep});'