Any idea to improve the API? The first that comes to my mind is 
singledispatch, but probably it's an overkill.

Jisoo Song

2021년 5월 12일 수요일 오후 12시 40분 11초 UTC+9에 asme...@gmail.com님이 작성:

> I also never liked how rewrite transforms the class name into a string
> for the method name. That makes it simple to implement for the basic
> cases, but it limits how expressive it can be. I think we can make a
> more expressive API which overlaps with the existing one, so that
> doesn't break compatibility.
>
> Aaron Meurer
>
> On Tue, May 11, 2021 at 9:10 PM JSS95 <jeeso...@snu.ac.kr> wrote:
> >
> > Current Basic.rewrite() allows three types as the rule: a str, a 
> function class, or a singleton instance. For example, 
> fibonacci(n).rewrite(S.GoldenRatio) calls 
> fibonacci(n)._eval_rewrite_as_GoldenRatio which returns the transformed 
> expression.
> >
> > The problem is that current design does not allow non-singleton instance 
> to be taken as rewrite rule. For example, I want to rewrite a boolean 
> expression which contains Eq(x, y) so that the equality is transformed to 
> Q.zero(x, y). expr.rewrite(Q.zero) calls expr._eval_rewrite_as_Predicate, 
> and I cannot define a logic which selectively works for Q.zero (but not for 
> Q.real, Q.infinite, etc).
> >
> > This will be even more problematic when we introduce functions as 
> instances. I plan to resolve it by redesigning _eval_refine and 
> _eval_rewrite_as_[...] methods, but it may break the backwards 
> compatibility so I would like to hear other opinions first.
> >
> > Jisoo Song
> >
> > --
> > 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/d980c0ca-1a52-4a48-b0a5-1e959d8ce025n%40googlegroups.com
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/d2661899-3c47-4523-8a58-29bd36048fddn%40googlegroups.com.

Reply via email to