[ python-Bugs-1060644 ] Remove .min() and .max() from Decimal
SourceForge.net
noreply at sourceforge.net
Fri Nov 5 04:27:41 CET 2004
Bugs item #1060644, was opened at 2004-11-04 20:44
Message generated for change (Comment added) made by tim_one
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1060644&group_id=5470
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 6
Submitted By: Facundo Batista (facundobatista)
Assigned to: Raymond Hettinger (rhettinger)
Summary: Remove .min() and .max() from Decimal
Initial Comment:
Raymond:
I propose to remove them as explicit methods because
the same behaviour can be achieved with the builtin
functions:
>>> Decimal("NaN").max(Decimal(8))
Decimal("8")
>>> max(Decimal("NaN"), Decimal(8))
Decimal("8")
(in the docs you put that .max() should return NaN if
either is a NaN, but it's not showing that behaviour
(and couldn't find any docs where says that it must to)).
I'm assigning this to you to have your opinion, but if
you're ok I can do the cleaning (code and docs).
I'm putting this as priority 6 because it will be more
painless to take them away before 2.4 final.
Regards,
. Facundo
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2004-11-04 22:27
Message:
Logged In: YES
user_id=31435
min() and max() are defined operations in the IBM spec, and
have to work the way the spec says they work. Here's a
reference for max:
http://www2.hursley.ibm.com/decimal/daops.html#refmax
Python's builtin min() and max() don't meet those
requirements. In particular, if the result is numeric it must be
rounded according to current context settings (the same as
applying the spec's unary plus).
Note that our docs are wrong if they say max returns NaN if
either input is a NaN. The spec says (for max):
If either operand is a NaN then the general rules apply,
unless one is a quiet NaN and the other is numeric, in
which case the numeric operand is returned.
I note that it says the same for min, so it's an odd sort of
ordering.
The implemented max seems correct:
>>> from decimal import Decimal as d
>>> eight = d("8")
>>> nan = d("NaN")
>>> nan.max(eight)
Decimal("8")
>>> eight.max(nan)
Decimal("8")
>>>
The builtin max() isn't even consistent here, giving a different
result depending on the order in which the operands are
specified:
>>> max(eight, nan)
Decimal("NaN")
>>> max(nan, eight)
Decimal("8")
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1060644&group_id=5470
More information about the Python-bugs-list
mailing list