kopia lustrzana https://github.com/sepandhaghighi/samila
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 : autopep8pull/140/head
rodzic
f3de359440
commit
73f8fe8ce0
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)",
|
||||
|
|
Ładowanie…
Reference in New Issue