Change from_str method name for muttable tree

This commit is contained in:
Bertrand Benjamin 2018-01-28 18:31:21 +03:00
parent 876a1fc63c
commit 251ec6c83b

View File

@ -62,14 +62,14 @@ class Tree(object):
:example: :example:
>>> t = MutableTree.fromStr("2+3*4") >>> t = Tree.from_str("2+3*4")
>>> print(t) >>> print(t)
+ +
> 2 > 2
> * > *
| > 3 | > 3
| > 4 | > 4
>>> t = MutableTree.fromStr("(2+3)*4") >>> t = Tree.from_str("(2+3)*4")
>>> print(t) >>> print(t)
* *
> + > +
@ -364,7 +364,7 @@ class Tree(object):
>>> nested_par = ("+", ( >>> nested_par = ("+", (
... ("*", (3, 4)), ... ("*", (3, 4)),
... 2)) ... 2))
>>> t = Tree.from_nested_parenthesis(nested_par) >>> t = Tree.from_str("3*4+2")
>>> [l for l in t.get_leafs()] >>> [l for l in t.get_leafs()]
[3, 4, 2] [3, 4, 2]
>>> {type(l) for l in t.get_leafs()} >>> {type(l) for l in t.get_leafs()}
@ -480,25 +480,25 @@ class MutableTree(Tree):
self.right_value = right_value self.right_value = right_value
@classmethod @classmethod
def fromStr(cls, expression): def from_str(cls, expression):
""" Initiate the MutableTree """ Initiate the MutableTree
:example: :example:
>>> t = MutableTree.fromStr("2+3*4") >>> t = MutableTree.from_str("2+3*4")
>>> print(t) >>> print(t)
+ +
> 2 > 2
> * > *
| > 3 | > 3
| > 4 | > 4
>>> t = MutableTree.fromStr("(2+3)*4") >>> t = MutableTree.from_str("(2+3)*4")
>>> print(t) >>> print(t)
* *
> + > +
| > 2 | > 2
| > 3 | > 3
> 4 > 4
>>> t = MutableTree.fromStr("4*(-2+3)") >>> t = MutableTree.from_str("4*(-2+3)")
>>> print(t) >>> print(t)
* *
> 4 > 4