how best to help Piecewise respond to `is_what` properties

16 views
Skip to first unread message

Chris Smith

unread,
Feb 21, 2020, 8:28:33 AM2/21/20
to sympy
In #18696 there is a problem of having `Piecewise(...).is_hypergeometric` return True when all the expressions it contains are hypergeometric. Quoting from my comment there:

The `is_hypergeometric` function has to be made to look for a `Piecewise` and return True if all the expressions in the `Piecewise` are hypergeometric. But better, `Piecewise` should be able to respond to all `is_what` requests by returning a value based on all its args meeting that criteria. `Piecewise` already knows how to handle a rewrite request (e.g. `Piecewise((factorial(x),x>0),(1,True)).rewite(gamma)` works. I believe the `core.basic.rewrite` and `core.basic._eval_rewrite` are able to work out how to rewrite the args of Piecewise without Piecewise having all `_eval_rewrite_as_what`. It would be good if we could do the same thing for all `is_what` properties.

What would be the best way to get Piecewise to do this?

/c 

Oscar Benjamin

unread,
Feb 21, 2020, 3:47:36 PM2/21/20
to sympy
It doesn't always make sense to delegate these properties to the
subexpressions of a Piecewise. For example knowing that the
subexpressions are hypergeometric functions does not mean that the
piecewise itself is a hypergeometric function.
> --
> 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+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/7223afaf-b89e-4dde-bf46-c7a1e3949e70%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages