That sounds right (and I'm sure it is).

What is worrying me slightly is that I have a vague memory that I once
edited that generic __invert__() code (possibly it was me who added
the is_one() test.

I would prbably be best to have __invert__() NotImplmented in the base
class, forcing all derived classes to implement their own (efficient,
sensible) version.

John

2008/12/5 daveloeffler <[EMAIL PROTECTED]>:
>
> I think you've uncovered a bug that had been masked by the is_one bug.
> If I'm not mistaken, I^-1 calls MultiplicativeGroupElement.__invert__,
> which tests whether self is one and if not returns 1/self. Obligingly,
> the coercion model (being asked to calculate 1/self) calls __invert__
> again!
>
> (I convinced myself of this by making is_one print a warning every
> time it is called. Then running your example code prints the warning
> over and over again, until the maximum recursion depth is exceeded and
> a segfault is raised.)
>
> David
>
> On Dec 5, 4:48 pm, "John Cremona" <[EMAIL PROTECTED]> wrote:
>> How worrying is this:
>>
>> In 3.2.1 we have:
>> {{{
>> sage: K.<a>=QuadraticField(2310)
>> sage: C=K.class_group()
>> sage: I=C.0
>> sage: I^-1
>> AttributeError
>> ...
>> AttributeError: 'FractionalIdealClass' object has no attribute 'is_one'}}}
>>
>> (cf #1052).
>>
>> Now I add one line in sage/rings/number_field/class_group.py, namely I add
>>     is_one = is_principal
>> inside the code for class  FractionalIdealClass.
>>
>> Result:
>> {{{
>> sage: K.<a>=QuadraticField(2310)
>> sage: C=K.class_group()
>> sage: I=C.0
>> sage: I^-1
>> /local/jec/sage-3.2.1.rc1/local/bin/sage-sage: line 202: 15960
>> Segmentation fault      sage-ipython "$@" -p sage -i
>>
>> }}}
>>
>> I did not think that adding one line pf python code could do that....
>>
>> John
> >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to