random generation for Equation
This commit is contained in:
parent
ba324ec995
commit
f648e94a37
@ -14,19 +14,24 @@ __all__ = ['Equation']
|
|||||||
class Equation(object):
|
class Equation(object):
|
||||||
"""A calculus expression. Today it can andle only expression with numbers later it will be able to manipulate unknown"""
|
"""A calculus expression. Today it can andle only expression with numbers later it will be able to manipulate unknown"""
|
||||||
|
|
||||||
# @classmethod
|
@classmethod
|
||||||
# def random(self, form="", conditions=[], val_min=-10, val_max=10):
|
def random(self, form="", conditions=[], val_min=-10, val_max=10):
|
||||||
# """Create a random expression from form and with conditions
|
"""Create a random expression from form and with conditions
|
||||||
#
|
|
||||||
# :param form: the form of the expression (/!\ variables need to be in brackets {})
|
:param form: the form of the expression (/!\ variables need to be in brackets {})
|
||||||
# :param conditions: condition on variables (/!\ variables need to be in brackets {})
|
:param conditions: condition on variables (/!\ variables need to be in brackets {})
|
||||||
# :param val_min: min value for generate variables
|
:param val_min: min value for generate variables
|
||||||
# :param val_max: max value for generate variables
|
:param val_max: max value for generate variables
|
||||||
#
|
|
||||||
# """
|
>>> Equation.random("{a}x + {b} = 0") # doctest:+ELLIPSIS
|
||||||
# random_generator = RdExpression(form, conditions)
|
< Equation [..., 0]>
|
||||||
# return Expression(random_generator(val_min, val_max))
|
>>> Equation.random("{a}x + {b} = _", conditions = ["{a}==2"]) # doctest:+ELLIPSIS
|
||||||
#
|
< Equation [2 x ...]>
|
||||||
|
|
||||||
|
"""
|
||||||
|
random_generator = RdExpression(form, conditions)
|
||||||
|
return Equation(random_generator(val_min, val_max))
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, exp_str = "", left_poly = Expression([0]), right_poly = Expression([0])):
|
def __init__(self, exp_str = "", left_poly = Expression([0]), right_poly = Expression([0])):
|
||||||
"""Create the equation
|
"""Create the equation
|
||||||
|
Loading…
Reference in New Issue
Block a user