How to use the simpleeval.DEFAULT_FUNCTIONS.update function in simpleeval

To help you get started, we’ve selected a few simpleeval examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fitoprincipe / geebap / geebap / expressions.py View on Github external
from .functions import drange
from geetools import tools
import math
import simpleeval as sval
import numpy as np
import copy

# FUNCIONES PARA simpleeval
CUSTOM_FUNCTIONS = {"sqrt": math.sqrt,
                    "exp": math.exp,
                    "max": max,
                    "min": min}

CUSTOM_NAMES = {"pi": math.pi}

sval.DEFAULT_FUNCTIONS.update(CUSTOM_FUNCTIONS)
sval.DEFAULT_NAMES.update(CUSTOM_NAMES)


class Expression(object):
    # TODO: Limitante: si hay mas de una variable
    """ El método principal de Expresiones() es map(**kwargs), el cual define
    la funcion que se usará en ImageCollection.map()

    :param expresion: Expression en formato texto. Se pueden usar algunas
        variables calculadas de la siguiente forma:

        - {max}: max_result valor del range
        - {min}: minimo valor del range
        - {mean}: mean del range
        - {std}: desvío estandar del range
        - {max_result}: max_result valor de los resultados