kopia lustrzana https://github.com/sepandhaghighi/samila
fix : autopep8 #79
rodzic
d96d04a03d
commit
b9b4b1efb8
|
@ -11,20 +11,22 @@ from .params import FIG_SAVE_SUCCESS_MESSAGE, NFT_STORAGE_SUCCESS_MESSAGE, DATA_
|
|||
from .params import ELEMENTS_LIST, ARGUMENTS_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)
|
||||
num_elements = random.randint(2, len(ELEMENTS_LIST) + 3)
|
||||
result = ""
|
||||
index = 1
|
||||
random_coef = "random.uniform(-1,1)"
|
||||
while(index<=num_elements):
|
||||
while(index <= num_elements):
|
||||
argument = random.choice(ARGUMENTS_LIST)
|
||||
result = result + random.choice(ELEMENTS_LIST).format(random_coef,argument)
|
||||
if index<num_elements:
|
||||
result = result + \
|
||||
random.choice(ELEMENTS_LIST).format(random_coef, argument)
|
||||
if index < num_elements:
|
||||
result = result + random.choice(OPERATORS_LIST)
|
||||
index = index + 1
|
||||
return result
|
||||
|
@ -260,6 +262,6 @@ def load_data(data):
|
|||
try:
|
||||
data = json.load(data)
|
||||
return data['data1'], data['data2'], data['matplotlib_version']
|
||||
except:
|
||||
except BaseException:
|
||||
raise samilaDataError(DATA_PARSING_ERROR)
|
||||
raise samilaDataError(DATA_TYPE_ERROR)
|
||||
|
|
|
@ -45,7 +45,8 @@ class GenerativeImage:
|
|||
if data is not None:
|
||||
self.data1, self.data2, matplotlib_version = load_data(data)
|
||||
if matplotlib_version != matplotlib.__version__:
|
||||
warn(MATPLOTLIB_VERSION_WARNING.format(matplotlib_version), RuntimeWarning)
|
||||
warn(MATPLOTLIB_VERSION_WARNING.format(
|
||||
matplotlib_version), RuntimeWarning)
|
||||
|
||||
def generate(
|
||||
self,
|
||||
|
|
|
@ -51,8 +51,28 @@ class Projection(Enum):
|
|||
RECTILINEAR = "rectilinear"
|
||||
|
||||
|
||||
ELEMENTS_LIST = ["{0}*math.cos({1})","{0}*math.sin({1})","{0}*{1}","{0}*abs({1})","{0}*math.ceil({1})","{0}*math.floor({1})"]
|
||||
ELEMENTS_LIST = [
|
||||
"{0}*math.cos({1})",
|
||||
"{0}*math.sin({1})",
|
||||
"{0}*{1}",
|
||||
"{0}*abs({1})",
|
||||
"{0}*math.ceil({1})",
|
||||
"{0}*math.floor({1})"]
|
||||
|
||||
ARGUMENTS_LIST = ["x*y","x","y","y-x","x-y","x+y","x**2","y**2","(x**2)*y","(y**2)*x","(x**2)*(y**3)","(x**3)*(y**2)","x*(y**3)","y*(x**3)"]
|
||||
ARGUMENTS_LIST = [
|
||||
"x*y",
|
||||
"x",
|
||||
"y",
|
||||
"y-x",
|
||||
"x-y",
|
||||
"x+y",
|
||||
"x**2",
|
||||
"y**2",
|
||||
"(x**2)*y",
|
||||
"(y**2)*x",
|
||||
"(x**2)*(y**3)",
|
||||
"(x**3)*(y**2)",
|
||||
"x*(y**3)",
|
||||
"y*(x**3)"]
|
||||
|
||||
OPERATORS_LIST = ["+","-"]
|
||||
OPERATORS_LIST = ["+", "-"]
|
||||
|
|
Ładowanie…
Reference in New Issue