[Patches] [ python-Patches-497487 ] support comparison of complex #s in fcmp
noreply@sourceforge.net
noreply@sourceforge.net
Sat, 29 Dec 2001 06:35:16 -0800
Patches item #497487, was opened at 2001-12-28 17:09
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=497487&group_id=5470
Category: Library (Lib)
Group: Python 2.3
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Neal Norwitz (nnorwitz)
Assigned to: Neal Norwitz (nnorwitz)
Summary: support comparison of complex #s in fcmp
Initial Comment:
>From #494872, there was a suggestion to use
test_support.fcmp() to compare complex numbers.
This patch adds a comparison test for complex
numbers to test_complex and the support to compare
complex numbers in test_support.fcmp().
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2001-12-29 06:35
Message:
Logged In: YES
user_id=33168
Checked in as 1.7 to test_complex.
I did what Tim suggested and did a vereq().
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-12-28 18:25
Message:
Logged In: YES
user_id=31435
test_complex.py already contains check_close() for fuzzy
comparison of complex numbers. The algorithm fcmp() uses
isn't good enough for the comparison needs test_complex
already has (I tried using it before, and it caused bogus
test failures on Pentium + gcc under Linux -- long story,
which I'll skip here).
So just use check_close, and skip the test_support part of
this patch (people reading the general-purpose test_support
shouldn't have to worry about the vagaries of complex
numbers). Or skip fuzzy comparison altogether! You have
an exact result here, and it would be fine to just do
test_support.vereq(complex(5.3, 9.8).conjugate(), 5.3-9.8j)
The folklore about never comparing floats for equality is
nonsense (although good advice in most cases <wink>).
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=497487&group_id=5470