def atan2(column1, column2): i = 0 column1 = mt.convert_num_col(column1) column2 = mt.convert_num_col(column2) result = list() while i < len(column1): if (isinstance(column1[i], int) or isinstance(column1[i], float)) and ( isinstance(column2[i], int) or isinstance(column2[i], float)): result.append(math.atan2(column1[i], column2[i])) else: result.append(column1[i]) i += 1 return result
def cos(column): i = 0 column = mt.convert_num_col(column) result = list() while i < len(column): if isinstance(column[i], int) or isinstance(column[i], float): result.append(math.cos(column[i])) else: result.append(column[i]) i += 1 return result
def atanh(column): i = 0 column = mt.convert_num_col(column) result = list() while i < len(column): if isinstance(column[i], int) or isinstance(column[i], float): if column[i] < 1 and column[i] > -1: result.append(math.atanh(column[i])) else: result.append("Error de dominio") list_errors_tg.append( "Error: 22003: la entrada esta fuera del dominio") else: result.append(column[i]) i += 1 return result
def tan(column): i = 0 column = mt.convert_num_col(column) result = list() while i < len(column): if isinstance(column[i], int) or isinstance(column[i], float): if (column[i] - (math.pi / 2)) % (math.pi) != 0: result.append(math.tan(column[i])) else: result.append("Error de dominio") list_errors_tg.append( "Error: 22003: la entrada esta fuera del dominio") else: result.append(column[i]) i += 1 return result
def acos(column): i = 0 column = mt.convert_num_col(column) result = list() while i < len(column): if isinstance(column[i], int) or isinstance(column[i], float): valor = "" if column[i] >= -1 and 1 >= column[i]: valor = str(math.acos(column[i])) else: valor = "Error de dominio" list_errors_tg.append( "Error: 22003: la entrada esta fuera del dominio") result.append(valor) else: result.append(column[i]) i += 1 return result
def atan2d(column1, column2): return mt.degrees(atan2(column1, column2))
def atand(column): return mt.degrees(atan(column))
def asind(column): return mt.degrees(asin(column))
def acosd(column): return mt.degrees(acos(column))
def tand(column): return mt.degrees(tan(column))
def sind(column): return mt.degrees(sin(column))
def cotd(column): return mt.degrees(cot(column))
def execute(self, environment): type_ = TYPE.NUMBER try: valores = [] types = [] for p in self.params: obj = p.execute(environment) val = obj.value t = obj.type if isinstance(val, pd.core.series.Series): val = val.tolist() valores.append(val) types.append(t) # Se toma en cuenta que las funcines matematicas # y trigonometricas producen un tipo NUMBER type_ = TYPE.NUMBER if self.function == "abs": value = mf.absolute(*valores) elif self.function == "cbrt": value = mf.cbrt(*valores) elif self.function == "ceil": value = mf.ceil(*valores) elif self.function == "ceiling": value = mf.ceiling(*valores) elif self.function == "degrees": value = mf.degrees(*valores) elif self.function == "div": value = mf.div(*valores) elif self.function == "exp": value = mf.exp(*valores) elif self.function == "factorial": value = mf.factorial(*valores) elif self.function == "floor": value = mf.floor(*valores) elif self.function == "gcd": value = mf.gcd(*valores) elif self.function == "lcm": value = mf.lcm(*valores) elif self.function == "ln": value = mf.ln(*valores) elif self.function == "log": value = mf.log(*valores) elif self.function == "log10": value = mf.log10(*valores) elif self.function == "mod": value = mf.mod(*valores) elif self.function == "pi": value = mf.pi() elif self.function == "power": value = mf.pow(*valores) elif self.function == "radians": value = mf.radians(*valores) elif self.function == "round": value = mf.round_(*valores) elif self.function == "sign": value = mf.sign(*valores) elif self.function == "sqrt": value = mf.sqrt(*valores) elif self.function == "trunc": value = mf.truncate_col(*valores) elif self.function == "width_bucket": value = mf.with_bucket(*valores) elif self.function == "random": value = mf.random_() elif self.function == "acos": value = trf.acos(*valores) elif self.function == "acosd": value = trf.acosd(*valores) elif self.function == "asin": value = trf.asin(*valores) elif self.function == "asind": value = trf.asind(*valores) elif self.function == "atan": value = trf.atan(*valores) elif self.function == "atand": value = trf.atand(*valores) elif self.function == "atan2": value = trf.atan2(*valores) elif self.function == "atan2d": value = trf.atan2d(*valores) elif self.function == "cos": value = trf.cos(*valores) elif self.function == "cosd": value = trf.cosd(*valores) elif self.function == "cot": value = trf.cot(*valores) elif self.function == "cotd": value = trf.cotd(*valores) elif self.function == "sin": value = trf.sin(*valores) elif self.function == "sind": value = trf.sind(*valores) elif self.function == "tan": value = trf.tan(*valores) elif self.function == "tand": value = trf.tand(*valores) elif self.function == "sinh": value = trf.sinh(*valores) elif self.function == "cosh": value = trf.cosh(*valores) elif self.function == "tanh": value = trf.tanh(*valores) elif self.function == "asinh": value = trf.asinh(*valores) elif self.function == "acosh": value = trf.acosh(*valores) elif self.function == "atanh": value = trf.atanh(*valores) elif self.function == "length": value = strf.lenght(*valores) elif self.function == "substring": type_ = TYPE.STRING value = strf.substring(*valores) elif self.function == "trim": type_ = TYPE.STRING value = strf.trim_(*valores) elif self.function == "get_byte": value = strf.get_byte(*valores) elif self.function == "md5": type_ = TYPE.STRING value = strf.md5(*valores) elif self.function == "set_byte": type_ = TYPE.STRING value = strf.set_byte(*valores) elif self.function == "sha256": type_ = TYPE.STRING value = strf.sha256(*valores) elif self.function == "substr": type_ = TYPE.STRING value = strf.substring(*valores) elif self.function == "convert_date": type_ = TYPE.DATETIME value = strf.convert_date(*valores) elif self.function == "convert_int": value = strf.convert_int(*valores) elif self.function == "encode": type_ = TYPE.STRING value = strf.encode(*valores) elif self.function == "decode": type_ = TYPE.STRING value = strf.decode(*valores) # Se toma en cuenta que la funcion now produce tipo DATE elif self.function == "now": type_ = TYPE.DATETIME value = datetime.now().strftime("%Y/%m/%d %H:%M:%S") else: # TODO: Agregar un error de funcion desconocida value = valores[0] if isinstance(value, list): if len(value) <= 1: value = value[0] else: value = pd.Series(value) return Primitive(type_, value, self.temp, self.row, self.column) except TypeError: expression.list_errors.append("Error: 42883: La funcion " + str(self.function) + "(" + str(type_) + ") no existe" + "\n En la linea: " + str(self.row)) except: expression.list_errors.append("Error: P0001: Error en funciones")