On Thu, 02 Nov 2006 15:47:25 -0800, Joel B. Mohler  
<[EMAIL PROTECTED]> wrote:
> On Thursday 02 November 2006 16:13, William Stein wrote:
>> On Thu, 02 Nov 2006 08:43:42 -0800, Joel B. Mohler
>> > sage: # this works
>> > sage: ZZ(maxima('1'))
>> > sage: CC(maxima('1'))
>> > sage: # this doesn't
>> > sage: CC(maxima('1+%i'))
>> > sage: # Why the difference?
>> >
>> > I attempted to follow the code-path through for the integer case to
>> > understand
>> > the working analogue, but I was confused and don't understand how the
>> > integer
>> > works.  If I'm pointed in a right direction to start, I'm sure I can
>> > work out
>> > a patch to fix the bug.]
>>
>> It's not a bug -- it's a lack of a feature.  Please implement
>> it and send me a patch.  You'll have to add another case (at
>> the bottom) to the call method in
>>      sage/rings/complex_field.py
>
> Unless I'm misunderstanding the intent of this advice, I don't agree.
> Certainly I could write something like:
>       if isinstance(x, maxima_element):
>                 return complex_number.ComplexNumber(self, x.real(),  
> x.imag())
> but this requires importing maxima stuff into the complex number which
> contributes to the (already messy) recursive includes.
>
> I propose to use methods like _complex_ in analogy with the _integer_  
> callback
> which the integer element __init__ calls.  This methodology does not  
> seem to
> be used nearly as consistently as I think it should be.  Is there a  
> reason
> for that?  Some sort of speed complaint in general?  (Certainly, in the  
> case
> of the maxima interface case, this is the least of our speed concerns.)

I completely agree with you!
You should definitely add a _complex_mpfr_field_ method:

     def _complex_mpfr_field_(self, CC):
         return make myself in CC.

In sage/rings/complex_field.py you need to add code that calls  
_complex_mpfr_field_.
Definitely this is the way to do things, since this is the approach taken  
in the
rest of Python, e.g., __int__ for coercion to an int is defined in the  
class
for an object.

  -- William

--~--~---------~--~----~------------~-------~--~----~
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-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to