random classmethod for polynoms
This commit is contained in:
parent
adce8e1348
commit
6ca79a4e69
@ -29,7 +29,8 @@ class Polynom(object):
|
|||||||
"""
|
"""
|
||||||
form = str(coefs_form)
|
form = str(coefs_form)
|
||||||
coefs = RdExpression(form, conditions)()
|
coefs = RdExpression(form, conditions)()
|
||||||
return Polynom(coef = eval(coefs), letter = letter)
|
coefs = [eval(i) if type(i)==str else i for i in eval(coefs)]
|
||||||
|
return Polynom(coef = coefs, letter = letter)
|
||||||
|
|
||||||
def __init__(self, coef = [1], letter = "x" ):
|
def __init__(self, coef = [1], letter = "x" ):
|
||||||
"""Initiate the polynom
|
"""Initiate the polynom
|
||||||
@ -347,8 +348,9 @@ if __name__ == '__main__':
|
|||||||
# print(repr(i))
|
# print(repr(i))
|
||||||
|
|
||||||
print("\n")
|
print("\n")
|
||||||
poly = Polynom.random(["{a**2}", "{2*a*b}", "{b**2}"])
|
poly = Polynom.random(["[{a**2}, {a}]", "{2*a*b}", "{b**2}"])
|
||||||
print(poly)
|
for i in poly.simplify():
|
||||||
|
print(i)
|
||||||
|
|
||||||
import doctest
|
import doctest
|
||||||
doctest.testmod()
|
doctest.testmod()
|
||||||
|
Loading…
Reference in New Issue
Block a user