On Mon, 25 Jul 2011 08:03:04 -0700 (PDT)
Steven Pollack <[email protected]> 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.html and
> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org