Example #1
0
    def __init__(self):
        """Creating command handlers"""
        self.updater = Updater(
            token="574757973:AAFXdejGo4o"
            "UkG-f_vVbyxTF0AA1ZYSoxNk",
            request_kwargs={"proxy_url": "https://94.177.216.109:8888"})
        self.dispatcher = self.updater.dispatcher
        self.parser = pee.Parser()

        start_handler = CommandHandler("start", self.start)
        self.dispatcher.add_handler(start_handler)

        help_handler = CommandHandler("help", self.help)
        self.dispatcher.add_handler(help_handler)

        list_handler = CommandHandler("list", self.list)
        self.dispatcher.add_handler(list_handler)

        plot_handler = CommandHandler("plot", self.plot)
        self.dispatcher.add_handler(plot_handler)

        last_handler = CommandHandler("last", self.last)
        self.dispatcher.add_handler(last_handler)

        clear_handler = CommandHandler("clear", self.clear)
        self.dispatcher.add_handler(clear_handler)
Example #2
0
def parse_expression(txt):
    """Parse the given expression and returns a parser object"""
    try:
        # remove leading =
        txt = txt.replace("=", "")
        return py_expression_eval.Parser().parse(jsonpath_to_variable(txt))
    except Exception:
        raise SchemaError('Bad expression format: %s' % txt)
Example #3
0
    def __init__(self, ex: str) -> None:
        """Create an Expression object.

        Receives the mathematical expression which shall be represented by the object as a string
        which will be parsed using py_expression_eval. For available operators, functions and
        constants see
        https://github.com/AxiaCore/py-expression-eval/#available-operators-constants-and-functions.
        In addition, the ** operator may be used for exponentiation instead of the ^ operator.

        Args:
            ex (string): The mathematical expression represented as a string
        """
        super().__init__()
        self.__string = str(ex)
        self.__expression = py_expression_eval.Parser().parse(
            ex.replace('**', '^'))
Example #4
0
# -*- coding:Utf-8 -*-
# !/usr/bin/env python3.5
"""

"""
import asyncio
import logging
import re
import py_expression_eval

parser = py_expression_eval.Parser()
from discord.ext import commands

logger = logging.getLogger('selfbot')
log_prefix = "[MATHS] "


def log_debug(message):
    # logger.debug(log_prefix + str(message))
    pass


def log_info(message):
    logger.info(log_prefix + str(message))


class maths_bot:
    def __init__(self, bot):

        self.cure = False
        self.activated = False  # Auto Activate the bot. You'll have to activate it with >maths activate otherwise
Example #5
0
"""Formula book.

Variable name conventions:
ET  =  energy technology
 L  =  level of facility
 T  =  mean temperature
US  =  universe speed
"""
import py_expression_eval

MET_ENERGY_CONSUMPTION = 'round(10 * L * (1.1 ^ L))'
CRY_ENERGY_CONSUMPTION = 'round(10 * L * (1.1 ^ L))'
DEU_ENERGY_CONSUMPTION = 'round(20 * L * (1.1 ^ L))'
SOLAR_PLANT_OUTPUT = '20 * L * (1.1 ^ L)'
FUSION_REACTOR_OUTPUT = '30 * L * (1.05 + ET * 0.01) ^ L'
FUSION_REACTOR_DEU_CONSUMPTION = '10 * L * US * (1.1 ^ L)'
SOLAR_SATELLITE_OUTPUT = '(T + 160) / 6'

_PARSER = py_expression_eval.Parser()


def F(formula, **kwargs):
    """Parse and evaluate a formula."""
    return int(_PARSER.parse(formula).evaluate(kwargs))
Example #6
0
import py_expression_eval as prsr
import matplotlib.pyplot as plt
import numpy as np
import sympy as sp

parser = prsr.Parser()
formula = str(input("f(x,y) = "))


def func_temp(formula_):
    parsed = parser.parse(formula_)
    vars = parsed.variables()

    def spec_func(x, y):
        return round(parsed.evaluate({vars[0]: x, vars[1]: y}), 2)

    return spec_func


lb_x = float(input("Type left boundary for 'x': "))
rb_x = float(input("Type right boundary for 'x': "))

lb_y = float(input("Type left boundary for 'y': "))
rb_y = float(input("Type right boundary for 'y': "))

segs = 500
rng_x = np.linspace(lb_x, rb_x, segs)
rng_y = np.linspace(lb_y, rb_y, segs)

func = func_temp(formula)