Random mode modification (#139)

* fix : random_equation_gen function updated

* fix : ARGUMENTS_LIST updated

* doc : CHANGELOG updated

* fix : random_equation_gen function updated

* fix : random_equation_gen function updated

* fix : autopep8
pull/140/head
Sepand Haghighi 2022-06-19 18:09:17 +04:30 zatwierdzone przez GitHub
rodzic f3de359440
commit 73f8fe8ce0
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 11 dodań i 2 usunięć

Wyświetl plik

@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- Random mode modified
## [0.8] - 2022-06-01
### Added
- `INVALID_COLOR_TYPE_ERROR` error

Wyświetl plik

@ -27,17 +27,22 @@ def random_equation_gen():
:return: equation as str
"""
num_elements = random.randint(2, len(ELEMENTS_LIST) + 3)
num_elements = random.randint(1, len(ELEMENTS_LIST))
result = ""
index = 1
random_coef = random.choice(RANDOM_COEF_LIST)
while(index <= num_elements):
argument = random.choice(ARGUMENTS_LIST)
if random.randint(0, 1) == 1:
argument = random.choice(ELEMENTS_LIST).format(
random_coef, argument)
result = result + \
random.choice(ELEMENTS_LIST).format(random_coef, argument)
if index < num_elements:
result = result + random.choice(OPERATORS_LIST)
index = index + 1
if random.randint(0, 1) == 1:
result = random.choice(ELEMENTS_LIST).format(random_coef, result)
return result
@ -106,7 +111,7 @@ def is_valid_color(color):
:type color: any format
:return: result as bool
"""
if color == None:
if color is None:
return True
try:
_ = matplotlib.colors.to_hex(color)

Wyświetl plik

@ -98,6 +98,8 @@ ARGUMENTS_LIST = [
"y**2",
"(x**2)*y",
"(y**2)*x",
"(y**2)+(x**2)",
"(y**2)-(x**2)",
"(x**2)*(y**3)",
"(x**3)*(y**2)",
"x*(y**3)",