At this point let me confess my ignorance of the internal mechanics of SymPy, I am very new to it and so am not sure what path the evaluation of a Piecewise follows. My assumption was that there is at some point a member function of Piecewise which gets control to recursively evaluate its subexpressions when a doit is called. It is this function which would return the original parent Piecewise expression if a recursion is detected, else the requested evaluation. But if this is not how it works then I leave the matter to the experts and simply note the presence of the bug :)
On Monday, July 8, 2019 at 11:35:04 AM UTC-3, Gagandeep Singh (B17CS021) wrote: > > So, basically you want `doit` not to evaluate certain expressions while > traversing the recursion. Isn't it? May be that isn't possible currently, > because for that, `evaluate` should be made a state of sympy object so > that, doit() can detect to leave it unevaluated but that would impact the > idea of doit(). You will have to set the evaluate attribute everytime you > want to call doit() to let it know whether that expression should be > touched or not. > Let's see if there is some better approach. > > On Monday, July 8, 2019 at 7:35:53 PM UTC+5:30, Tomasz Pytel wrote: >> >> In this case that would not be necessary as a recursive evaluation is >> literally a copy of the original expression and so could be checked for >> upon execution of the doit at which point the original expression should be >> returned. >> >> On Monday, July 8, 2019 at 11:03:15 AM UTC-3, Gagandeep Singh (B17CS021) >> wrote: >>> >>> I personally believe that all doits should be called with one outer >>> doit. May be this can be efficiently implemented with a stack. Let's see >>> what others have to say. >> >> -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/cc8dd5dd-a1e6-405c-81b8-a2269495128f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.