Hi Aaron,

Thank you for your reply.

If you want to give the fields names I guess you should use 
> UndefinedFunction. Note that UndefinedFunction('f') dynamically creates a 
> subclass of AppliedUndef called "f". 
>

The problem is that I need this object to participate in expressions even 
without being applied (that is, both `f` and `f(x)` should be usable in 
expressions), and UndefinedFunction cannot do that. I was thinking about 
subclassing a Symbol and overriding __call__ to return an applied function 
(that's where the error checking will happen, too). Another variant would 
be to give the user a function applied to native dimensions right away, and 
override __call__ in the UndefinedFunction derivative (that would make 
printing more verbose than necessary, but I can live with that). Which way 
do you think fits better in sympy design?
 

> I think what you are doing is right, although let us know if you run into 
> issues (SymPy has many bugs where things don't work correctly if you 
> subclass things).  It's clear to me that we should make this sort of thing 
> easier, though.
>

The main problem is that I do not know which conventions should my 
subclassed objects conform to (besides the primary invariant). For 
instance, do I understand it correctly that sympy caches objects purely for 
performance reasons, and for two objects to be equal it is enough to have 
equal _hashable_content()? If I want a custom differentiation behavior 
(e.g. `f.diff(x)` equivalent to `f(x).diff(x)`), do I need to override 
diff(), or some underscored method?

-- 
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/ab71d1a9-8f3e-4006-8cbd-7632dedcb4a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to