[Python-bugs-list] [ python-Bugs-543387 ] bug? floor divison on complex
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 21 May 2002 10:46:46 -0700
Bugs item #543387, was opened at 2002-04-13 08:46
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=543387&group_id=5470
Category: Python Interpreter Core
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Hernan Martinez Foffani (hfoffani)
Assigned to: Raymond Hettinger (rhettinger)
Summary: bug? floor divison on complex
Initial Comment:
PEP 238 says:
"For complex numbers, // raises an exception, since
floor() of a complex number is not allowed."
But on 2.3 (and on CVS) complex floor division returns
divmod[0]
Is this a bug on complexobject.c or the PEP wasn't updated?
Regards,
-Hernan
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2002-05-21 12:46
Message:
Logged In: YES
user_id=80475
Separated the \deprecated sections. Revised patch attached.
----------------------------------------------------------------------
Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2002-05-21 11:10
Message:
Logged In: YES
user_id=3066
The \deprecated markup should always be a separate paragraph
(or list item). Please revise the doc patch and re-submit
for review. (But thanks for working on this; the content is
good!)
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2002-05-13 01:29
Message:
Logged In: YES
user_id=80475
Fred, here's a doc patch.
Okay to commit and close this bug?
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-15 07:37
Message:
Logged In: YES
user_id=6380
Note: complex % is also being deprecated.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-14 20:42
Message:
Logged In: YES
user_id=6380
Fred, can you fix the docs?
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-14 20:36
Message:
Logged In: YES
user_id=6380
OK, I'll add the deprecation warning.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-04-14 20:23
Message:
Logged In: YES
user_id=31435
Heh. divmod(c1, c2)[0] for complexes returns
floor((c1/c2).real)
according to the Reference Manual (5.6 Binary arithmetic
operations), and it looks like the code implements that
just so. The Library manual's "Builtin Functions" section
only mentions ints, longs and floats, while the same
manual's "2.2.4 Numeric Types" claims, in a footnote,
that "Builtin Functions" told the full truth about divmod.
The primary lesson I take from this is that a .chm file is
a truly wonderful way to search the docs <wink>.
I don't think divmod is useful for complexes, and would be
happy to see it go away. But I guess that means taking the
full-blown deprecation path.
I note that the original complexobject.c didn't implement
divmod. The current divmod appears to derive from a patch
contributed by Tim Hochberg, in rev 2.10 in 1996. You
(Guido) added a question mark to the checkin comment, so I
figure it never made much sense to you either.
I agree floor divsion and divmod(...)[0] should do the same
thing, whatever that is.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-14 19:44
Message:
Logged In: YES
user_id=6380
Hm. I believe that if divmod() returns something, // should
return the same thing (well, divmod()[0]). But what on earth
does divmod() do on two complex numbers??? Does it make
sense to have divmod() on complex at all? Assigned to Tim
for a ruling.
----------------------------------------------------------------------
Comment By: Hernan Martinez Foffani (hfoffani)
Date: 2002-04-14 18:24
Message:
Logged In: YES
user_id=112690
As suggested by Tim I'll upload here the patch and the test
for this bug.
The patch clears nb_true_divide entry and deletes the
complex_int_div function.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=543387&group_id=5470