Hi David,
If you type
sage: X = test(H)
you notice that doesn't give an error. So the problem occurs when
Sage tries to print your object X. Since you haven't defined a
_repr_() method for your class, Sage tries to use the one inherited
from the hyperelliptic curve class. You can see the code for that by
typing
sage: H._repr_?
The first line of code wants to get the hyperelliptic polynomials,
and that's where things break down. I guess you have to write your
own _repr_() method for your inherited class. It can be as simple as
class test
(sage.schemes.hyperelliptic_curves.hyperelliptic_rational_field.HyperellipticCurve_rational_field):
def __init__(self,C):
self.C = C
def _repr_(self):
return self.C._repr_()
Disclaimer: I haven't actually tried this out, but I'd be surprised if
it didn't work :)
Of course, if you will eventually have more info that you want printed
about your class, you can customise _repr_() to your liking.
Best,
Alex
On Thu, Nov 05, 2009 at 01:09:25PM -0800, David Holmes wrote:
>
> Hi,
>
> I am trying to write a subclass of the class of hypereliptic curves
> over QQ, for example:
>
> class test
> (sage.schemes.hyperelliptic_curves.hyperelliptic_rational_field.HyperellipticCurve_rational_field):
> def __init__(self,C):
> self.C = C
>
>
> then in sage I type
>
> R.<x> = QQ[]
> H = HyperellipticCurve(x^9+1)
> test(H)
>
> the last lline gives a long string of error traceback ending
> ...
> /usr/local/sage/sage-4.2/local/lib/python/pprint.pyc in _safe_repr
> (object, context, maxlevels, level)
> 318 return format % _commajoin(components), readable,
> recursive
> 319
> --> 320 rep = repr(object)
> 321 return rep, (rep and not rep.startswith('<')), False
> 322
>
> /usr/local/sage/sage-4.2/local/lib/python2.6/site-packages/sage/
> structure/sage_object.so in
> sage.structure.sage_object.SageObject.__repr__ (sage/structure/
> sage_object.c:1416)()
>
> /usr/local/sage/sage-4.2/local/lib/python2.6/site-packages/sage/
> schemes/hyperelliptic_curves/hyperelliptic_generic.pyc in _repr_(self)
> 93 """
> 94
> ---> 95 f, h = self._hyperelliptic_polynomials
> 96 R = self.base_ring()
> 97 y = self._printing_ring.gen()
>
> AttributeError: 'test' object has no attribute
> '_hyperelliptic_polynomials'
>
>
> I am not sure what to do about this, any help will be much
> appreciated.
>
> Thank you,
>
> David Holmes
>
> >
--
Alex Ghitza -- Lecturer in Mathematics -- The University of Melbourne
-- Australia -- http://www.ms.unimelb.edu.au/~aghitza/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---