Also, this might help: http://docs.sympy.org/latest/guide.html#sympy-s-architecture
Jason moorepants.info +01 530-601-9791 On Sun, Mar 30, 2014 at 8:21 AM, Jason Moore <moorepa...@gmail.com> wrote: > Hi Richard, > > What is the big picture of what you want to do? And if you post your code > it is easier for us to understand the details and we can help you. > > sympy.physics.vector.Vector unfortunately and/or fortunately does not > subclass from basic SymPy types. The reason is that the current vectors are > mutable by design whereas basic sympy classes aren't. This, as you've found > causes issues depending on what you are trying to do. There is a proposal > to create a new vector package with immutable vectors this summer: > > > https://github.com/pydy/pydy/wiki/GSoC-2014-Application%3A-srjoglekar246%3A-sympy.vector-module > > > > > Jason > moorepants.info > +01 530-601-9791 > > > On Sat, Mar 29, 2014 at 9:14 PM, richard B <rich...@boyd.org.nz> wrote: > >> I'm trying to create a number of custom classes to integrate with Sympy. >> >> I need to know: >> What base classes I should subclass for different purposes. >> What sympy "magic methods' I should subclass to hook into the arithmetic >> and simplification machinery. Also how do I look for examples of use? Using >> github code search does not seem to work well - searching for "class >> Number" brings up* "class NumberOp"* but not Number! >> >> Eventually I would like to create a wrapper for my numpy based physics >> Vector classes. I would love to use the physics Vector class, but I can't >> figure out how it works enough to extend/subclass it without breaking it. >> >> In my first play project I have tried to: >> Customise representation, especially latex >> Customise simplification >> Customise addition with integers >> >> I've tried overloading a large number of methods to do what I want, to no >> avail. >> >> For instance, when I overloaded .subs, it ignored it when I called subs >> t = Testf(n) >> (2*t+2).subs(n,3) >> >> It did not call my subs, it did it automatically. >> >> [I think I've now cracked subs now - overload _subs?] >> >> I know about the eval class method, and I think I know how to use it, >> though looking at sympy source code was of limited use, as many classes >> seem to just override __new__ instead. >> >> My __add__ works fine, but only when I create the expression with my >> custom type. I've got no idea how to get the Add class to call my custom >> adder after a substitution. I've tried a number of methods and tried >> simplifying after substitution, but it either doesn't work at all (Basic >> subclass), or it bypasses my class methods entirely (AtomicExpr subclass). >> >> Different things are supported depending on whether I subclass Basic or >> AtomicExpr. And physics Vector does not seem to subclass anything?!! Where >> can I find out what I should be subclassing for what purpose? I can only >> find an out-of-date hierarchy on the old googlecode site. >> >> Anyway, Sympy looks very promising at the moment, but I'm finding it hard >> to get started in developing for it. >> >> >> >> -- >> 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 http://groups.google.com/group/sympy. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/sympy/023acb62-3043-4ee2-a559-346d87c689c1%40googlegroups.com<https://groups.google.com/d/msgid/sympy/023acb62-3043-4ee2-a559-346d87c689c1%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> 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 sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAP7f1AibkxPkAJf3CCoG6rJ-nj86mY5jwYH8r7merg2fvBaz0g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.