diff --git a/mapytex/calculus/API/expression.py b/mapytex/calculus/API/expression.py index be39eda..5f3fe63 100644 --- a/mapytex/calculus/API/expression.py +++ b/mapytex/calculus/API/expression.py @@ -97,7 +97,7 @@ class Expression(object): :example: >>> Expression.random("{a}/{a*k}") # doctest: +SKIP - >>> Expression.random("{a}/{a*k} - 3*{b}", variables_scope={'a':{'min_max':(10, 30)}}) # doctest +SKIP + >>> Expression.random("{a}/{a*k} - 3*{b}", variables_scope={'a':{'min_max':(10, 30)}}) # doctest: +SKIP """ diff --git a/mapytex/calculus/core/random/__init__.py b/mapytex/calculus/core/random/__init__.py index ee6afb9..70bbe24 100644 --- a/mapytex/calculus/core/random/__init__.py +++ b/mapytex/calculus/core/random/__init__.py @@ -7,7 +7,7 @@ # Distributed under terms of the MIT license. """ -Tools to extract random nodes, random variables, generate random values and +Tools to extract random leafs, random variables, generate random values and fill new trees Flow @@ -15,9 +15,9 @@ Flow Tree with RdLeaf | -| Extract nodes +| Extract rdLeaf | -List of nodes to generate +List of leafs to generate | | extract_rv | @@ -27,9 +27,9 @@ List random variables to generate | Dictionnary of generated random variables | -| Compute nodes +| Compute leafs | -Dictionnary of computed nodes +Dictionnary of computed leafs | | Replace | diff --git a/mapytex/calculus/core/str2.py b/mapytex/calculus/core/str2.py index 85cf785..a7098d4 100644 --- a/mapytex/calculus/core/str2.py +++ b/mapytex/calculus/core/str2.py @@ -836,6 +836,31 @@ def rdstr2(sink): return pipeline +def rdstr2(sink): + """ Return a pipeline which parse random expression and with sink as endpoint + + :example: + >>> rdstr2list = rdstr2(list_sink) + >>> rdstr2list("{a}+{a*b}-2") + [, '+', , '+', ] + """ + lfop = lookfor(is_operator) + operator_corout = partial(concurent_broadcast, lookfors=[lfop]) + + def pipeline(expression): + str2_corout = look_for_rdleaf( + lookforNumbers(operator_corout(missing_times(moify_cor(pparser(sink))))) + ) + + for i in expression.replace(" ", ""): + str2_corout.send(i) + a = str2_corout.throw(STOOOP) + + return a + + return pipeline + + str2nestedlist = str2(list_sink)