Serhiy Storchaka added the comment:
Note the catch on 2.7. triangular(10, 10.0) returns 10.0, but triangular(10,
10.0, 10.0) returns 10. If then you divide by the result...
I proposed change return low to return low + 0.0.
--
___
Python tracker
Raymond Hettinger added the comment:
Thanks Stefan. For us, I don't see the need to add a restriction, possibly
breaking code that is currently working fine (with high mode = low). The
important part is that we now allow low==mode or high==mode and have a smooth
transition to low==high.
Roundup Robot added the comment:
New changeset 7ea6c8eb91e2 by Raymond Hettinger in branch '3.4':
Issue 13355: Make random.triangular degrade gracefully when low == high.
http://hg.python.org/cpython/rev/7ea6c8eb91e2
--
___
Python tracker
Roundup Robot added the comment:
New changeset 6dc5c4ba7544 by Raymond Hettinger in branch '2.7':
Issue 13355: Make random.triangular degrade gracefully when low == high.
http://hg.python.org/cpython/rev/6dc5c4ba7544
--
___
Python tracker
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
resolution: - fixed
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
Stefan Krah added the comment:
While NumPy is of course not normative, this is what they do:
numpy.random.triangular(left=1, right=2, mode=0)
Traceback (most recent call last):
File stdin, line 1, in module
File mtrand.pyx, line 3218, in mtrand.RandomState.triangular
Raymond Hettinger added the comment:
Attaching patch
--
Added file: http://bugs.python.org/file35333/fix_triangular.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
Serhiy Storchaka added the comment:
So now triangular(10, 10, 20) will always return 10?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
Larry Hastings added the comment:
I haven't looked at this in depth but it sounds like this is a legitimate
concern. I'd like it fixed for 3.4, preferably before rc1.
--
nosy: +larry
___
Python tracker rep...@bugs.python.org
Raymond Hettinger added the comment:
[Serhiy]
Raymond, could you please make a decision
Yes, I will this week.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
Serhiy Storchaka added the comment:
Raymond, could you please make a decision or delegate this issue to Mark,
Terry, Andrew or me?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
Changes by Serhiy Storchaka storch...@gmail.com:
--
stage: committed/rejected - needs patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
Changes by Mark Dickinson dicki...@gmail.com:
--
nosy: -mark.dickinson
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
___
Mark Dickinson added the comment:
Raymond: have you had time to look at this yet?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
___
Raymond Hettinger added the comment:
Soonish
--
priority: normal - low
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
___
Raymond Hettinger added the comment:
I haven't had a chance to look at this one yet and am reopening.
The triangular code was originally written so that low and high could be
reversed and it would still work. I don't want to break any code that might be
relying on that.
Andrew Svetlov, this
Raymond Hettinger added the comment:
Andrew Svetlov, please revert the commit. It breaks code that may have been
working before the commit. Also, I don't want to change the exceptions being
raised in old versions of Python.
--
resolution: fixed -
Mark Dickinson added the comment:
I agree that the issue_13355.patch commit should be reverted: the code used to
work fine in the case high mode low, and now does not. (Similarly, a call
to random.uniform(2.0, 1.0) works as expected at the moment.)
Really, I think all that's needed here is
Roundup Robot added the comment:
New changeset e948154af406 by Andrew Svetlov in branch '3.3':
Revert changes for #13355 by request from Raymond Hettinger
http://hg.python.org/cpython/rev/e948154af406
New changeset 39bbbf5d7b01 by Andrew Svetlov in branch 'default':
Revert changes for #13355 by
Andrew Svetlov added the comment:
Reverted. Sorry.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
___
Python-bugs-list mailing list
Roundup Robot added the comment:
New changeset c40e36a49033 by Andrew Svetlov in branch '3.3':
Issue #13355: Raise ValueError on random.triangular call with invalid params.
http://hg.python.org/cpython/rev/c40e36a49033
New changeset 613eb432b152 by Andrew Svetlov in branch 'default':
Issue
Roundup Robot added the comment:
New changeset 1062c66e9bdc by Andrew Svetlov in branch '2.7':
Issue #13355: Raise ValueError on random.triangular call with invalid params.
http://hg.python.org/cpython/rev/1062c66e9bdc
--
___
Python tracker
Changes by Andrew Svetlov andrew.svet...@gmail.com:
--
versions: -Python 3.2
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
___
Andrew Svetlov added the comment:
Test for the issue_13355.patch is incorrect, please fix.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
Yuriy Senko added the comment:
Added validation of input data. Check whether low = mode = high. If low ==
high return low as a result.
--
nosy: +Chaka_bum, asvetlov
Added file: http://bugs.python.org/file29709/issue_13355.patch
___
Python tracker
Raymond Hettinger added the comment:
I'll look at the patch shortly. At first glance, it looks over-engineered to
me.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
Changes by Serhiy Storchaka storch...@gmail.com:
--
keywords: +easy
nosy: +serhiy.storchaka
versions: +Python 3.4
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
Serhiy Storchaka added the comment:
Here is a patch.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
___
Python-bugs-list mailing list
Changes by Serhiy Storchaka storch...@gmail.com:
--
stage: needs patch - patch review
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
___
Mark Dickinson added the comment:
Here is a patch.
Where? :-)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
___
Python-bugs-list
Serhiy Storchaka added the comment:
Now it is here.
--
Added file: http://bugs.python.org/file28975/random_triangular.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
Mark Dickinson added the comment:
Looks fine to me. Raymond: can this be applied?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
___
Mark Dickinson added the comment:
One minor comment: I'd prefer it if the second test were elif low == high:,
since that more obviously guards against the division by zero.
--
___
Python tracker rep...@bugs.python.org
Serhiy Storchaka added the comment:
One minor comment: I'd prefer it if the second test were elif low ==
high:, since that more obviously guards against the division by zero.
It is written deliberately. What if low == high != mode?
--
___
Python
Mark Dickinson added the comment:
What if low == high != mode?
Then we've got garbage in, garbage out; that case doesn't worry me.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
Serhiy Storchaka added the comment:
An exception is better than a garbage result. But I agree, triangular()
currently is not protectet against a situation when mode is not in low--high
range.
--
___
Python tracker rep...@bugs.python.org
Mark Dickinson added the comment:
An exception is better than a garbage result.
Agreed. And ZeroDivisionError is the wrong exception, too---ValueError would
be better. But I'm content that the current patch fixes the immediate issue.
--
___
Raymond Hettinger raymond.hettin...@gmail.com added the comment:
I've got this one.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13355
___
___
Terry J. Reedy tjre...@udel.edu added the comment:
3.2 doc entry:
random.triangular(low, high, mode)
Return a random floating point number N such that low = N = high and with the
specified mode between those bounds. The low and high bounds default to zero
and one. The mode argument defaults
39 matches
Mail list logo