From c69edd5a0715e056adf69e66c78cfd2cf73193fe Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 14 Dec 2021 18:43:34 +0330 Subject: [PATCH] feat : random equations mode added #32 --- samila/functions.py | 19 +++++++++++++++++++ samila/genimage.py | 6 ++++-- samila/params.py | 7 +++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/samila/functions.py b/samila/functions.py index 72ae473..d17ca69 100644 --- a/samila/functions.py +++ b/samila/functions.py @@ -7,8 +7,27 @@ import json from .params import Projection, DEFAULT_PROJECTION, VALID_COLORS, NFT_STORAGE_API, OVERVIEW from .params import DATA_TYPE_ERROR, DATA_PARSING_ERROR, NO_FIG_ERROR_MESSAGE from .params import FIG_SAVE_SUCCESS_MESSAGE, NFT_STORAGE_SUCCESS_MESSAGE, DATA_SAVE_SUCCESS_MESSAGE +from .params import ELEMENTS_LIST, ARGUMENT_LIST, OPERATORS_LIST from .errors import samilaDataError +def random_equation_gen(): + """ + Generate random equation. + + :return: equation as str + """ + num_elements = random.randint(2,len(ELEMENTS_LIST) + 3) + result = "" + index = 1 + while(index<=num_elements): + random_coef1 = "random.uniform(-1,1)" + argument = random.choice(ARGUMENT_LIST) + result = result + random.choice(ELEMENTS_LIST).format(str(random_coef1),argument) + if index