On Thursday, 20 April 2017 21:23:54 UTC+2, Aaron Meurer wrote:
>
>
>
> On Thu, Apr 20, 2017 at 6:12 AM, Francesco Bonazzi <[email protected]
> <javascript:>> wrote:
> >
> >
> > On Wednesday, 19 April 2017 21:51:08 UTC+2, Aaron Meurer wrote:
> >>
> >> Performance is a valid concern. We should definitely check that.
> >>
> >> The __slots__ part I don't know. That could probably be done
> differently.
> >>
> >
> > I didn't like that part too. Has anyone a better idea?
> >
> >> Regarding the implementation itself, how would you do it? The ability
> >> to make Mul or Add do custom stuff for custom objects is a very
> >> commonly requested feature. Would you keep it unimplemented, or do it
> >> some other way?
> >
> >
> > Yes, we really need this feature.
> >
> > Ideally we want to extend such mechanism to functions as well.
>
> For functions, dispatch works nicely. In fact, most functions are
> single-argument, so you only need single dispatch, which is basically
> SymPy's _eval_*thing* mechanism. We could extend Function so that it
> dispatches before eval() is called on the subclass (say, sin(x) could call
> x._eval_function(sin)). At least, that should work when nargs = 1. For
> nargs > 1, you need something more complicated.
>
>
Suppose we have the exponential of a MatrixSymbol, how do we transmit the
information that the result of the exponential function is a matrix?
Suppose you have the expression:
exp(MatrixSymbol("M", 3, 3)) + MatrixSymbol("A", 2, 2)
It would be desirable to raise a *ShapeError*.
Francesco's solution maybe isn't the most general, but it seems simple, and
> capable of handling the use-cases I know of.
>
I had a thought about using the arguments instead of a new __slots__. That
is, add an extra argument to the *args* that is hidden when printing, but
if *Mul* or* Add* meet it, they should post-process the other *args *and
pass it further. But this could also have its cons.
> Aaron Meurer
>
> >
> >
> >>
> >> Aaron Meurer
> >>
> >> On Wed, Apr 19, 2017 at 3:46 PM, Ronan Lamy <[email protected]> wrote:
> >> > Le 19/04/17 à 19:00, Francesco Bonazzi a écrit :
> >> >>
> >> >>
> >> >>
> >> >> On Wednesday, 19 April 2017 17:05:08 UTC+2, Ronan Lamy wrote:
> >> >>
> >> >> Le 18/04/17 à 21:28, Francesco Bonazzi a écrit :
> >> >> > I'm gonna merge this PR soon:
> >> >> >
> >> >> > https://github.com/sympy/sympy/pull/12508
> >> >> <https://github.com/sympy/sympy/pull/12508>
> >> >>
> >> >> Wow, that's horrifying! Good luck maintaining it!
> >> >>
> >> >>
> >> >> Why is it horrifying?
> >> >
> >> >
> >> > Well, using __new__ in the first place is a big WTF (and yes, I know
> >> > that
> >> > sympy is pretty much stuck with it forever), but layering a hook to a
> >> > whole
> >> > new programming paradigm inside it is evil genius. Bonus horror points
> >> > for
> >> > introspecting __slots__ and doing such fundamental changes to solve a
> >> > minor
> >> > issue.
> >> >
> >> > And BTW, has anybody checked the impact on performance? IIUC, that
> adds
> >> > a
> >> > non-trivial amount of work to every Add or Mul instantiation.
> >> >
> >> > That being said, don't mind me. As long as I don't have to debug it,
> >> > that
> >> > code won't bother me.
> >> >
> >> > --
> >> > 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 [email protected].
> >> > To post to this group, send email to [email protected].
> >> > 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/086034c8-3ad1-4059-7424-d358f3de9b92%40gmail.com
> .
> >> >
> >> > For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > 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 [email protected] <javascript:>.
> > To post to this group, send email to [email protected]
> <javascript:>.
> > 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/03cf6d1f-83f6-4844-9b5c-753e947f90ce%40googlegroups.com
> .
> >
> > For more options, visit https://groups.google.com/d/optout.
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
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/c4dbda7f-1798-4f2e-9103-b9a6f310f52d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.