Incidentally, if you and Burcin think this is worthwhile in general, please feel free to make a Trac ticket so that it's easier for others to test these ideas out. Thank you - looking forward to it!
- kcrisman On Jul 29, 11:43 am, Steven Pollack <stevenlawrencepoll...@gmail.com> wrote: > Thanks for the explanation! I haven't had a chance to try installing > the patch (I got caught up taking care of some other side-projects), > however I can't thank you enough for the help. > > I now have a new question (@Robert): if the Expression class wasn't > made with subclassing in mind, how did the makers of sage envision > users to build their own classes (while still utilizing expressions)? > > I'm new to OOP, but the impression I'm (now) under is that without > Burcin's patch, we have to do something like: > > class newObject(): > def __init___(self, expression, *variables, **attributes): > [var('{0}'.format(variable)) for variable in > variables] > self.exp = expression > for options in attributes.items(): > self.attr[option] = attributes(option) > ? > > Thanks, > > Steven > > On Jul 26, 3:15 pm, Burcin Erocal <bur...@erocal.org> wrote: > > > > > On Mon, 25 Jul 2011 08:03:04 -0700 (PDT) > > > Steven Pollack <stevenlawrencepoll...@gmail.com> wrote: > > > Is the syntax for this class > > > > t = new_exp(SR, symbolic_expression)? > > > > So that sage: t returns symbolic_expression? > > > t is an instance of new_exp, which inherits from Expression. The value > > of the internal GiNaC object stored in both is determined by the second > > argument. > > > You could define other member functions or store attributes in your > > class. Though you need to take care what happens to the attributes > > when you do any arithmetic. > > > sage: class new_exp(Expression): > > def __init__(self, parent, value, attribute): > > self.attr = attribute > > super(self.__class__, self).__init__(parent, value) > > ....: > > sage: t = new_exp(SR, x, 2) > > sage: t > > x > > sage: t.attr > > 2 > > sage: t.new_method(5) > > x - 5 > > sage: u = t+t > > sage: u.new_method(5) > > 2*x - 5 > > sage: u.attr > > <snip> > > AttributeError: 'new_exp' object has no attribute 'attr' > > sage: type(u) > > <class '__main__.new_exp'> > > sage: u > > 2*x > > sage: v = u/2 > > sage: v.new_method(5) > > x - 5 > > sage: v.attr > > <snip> > > AttributeError: 'new_exp' object has no attribute 'attr' > > > > Second, I'm not entirely sure I understand how this patch was made, > > > let alone how to install it. I skimmed over > > >http://www.sagemath.org/doc/developer/patching_spkgs.htmland > > >http://www.sagemath.org/doc/developer/producing_spkgs.html#chapter-spkg > > > but found the whole thing to be a bit over my head (I'm a newbie, > > > sorry). > > > > Is there a series of instructions you could provide me for the > > > installation of your patch? I'm sure you're very busy, so I really do > > > appreciate the effort. > > > You need to look at a different section of the guide: > > >http://sagemath.org/doc/developer/walk_through.html > > > Here is a quick summary: > > > - Go to your SAGE_ROOT, the base directory of your sage installation > > - Go to the directory with the sage library sources > > cd devel/sage > > - import the patch into a patch queue > > hg qimport <URL_of_patch> > > - apply the patch > > hg qpush > > - go back to SAGE_ROOT > > cd ../.. > > - build the library with changes > > ./sage -b > > - start Sage and enjoy > > ./sage > > > Cheers, > > Burcin -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org