summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2013-04-13 15:05:44 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2013-04-13 15:05:44 (GMT)
commit75f1fc27c3d14d8f75010f5612270077de6f1995 (patch)
tree9cbd7b9ab13480f56f2e63e443be57f07c6f8836
parentf794b143d32c30f4a910ff19bded3e62c20313e1 (diff)
downloadcpython-75f1fc27c3d14d8f75010f5612270077de6f1995.zip
cpython-75f1fc27c3d14d8f75010f5612270077de6f1995.tar.gz
cpython-75f1fc27c3d14d8f75010f5612270077de6f1995.tar.bz2
Revert changes for #13355 by request from Raymond Hettinger
-rw-r--r--Lib/random.py10
-rw-r--r--Lib/test/test_random.py29
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS3
4 files changed, 1 insertions, 42 deletions
diff --git a/Lib/random.py b/Lib/random.py
index 8560fb9..af04ab2 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -367,16 +367,6 @@ class Random(_random.Random):
http://en.wikipedia.org/wiki/Triangular_distribution
"""
- # Sanity check. According to the doc low must be less or equal to
- # high. And mode should be somewhere between these bounds.
- if low > high:
- raise ValueError('high cannot be less then low.')
- if mode is not None and (mode < low or mode > high):
- raise ValueError('mode must be between low and high.')
-
- if high == low:
- return low
-
u = self.random()
c = 0.5 if mode is None else (mode - low) / (high - low)
if u > c:
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 75e1afc..3316415 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -43,33 +43,6 @@ class TestBasicOps(unittest.TestCase):
self.assertRaises(TypeError, self.gen.seed, 1, 2)
self.assertRaises(TypeError, type(self.gen), [])
- def test_triangular(self):
- # Check that triangular() correctly handles bad input. See issue 13355.
- # mode > high.
- with self.assertRaises(ValueError):
- random.triangular(mode=2)
- with self.assertRaises(ValueError):
- random.triangular(low=1, high=10, mode=11)
- with self.assertRaises(ValueError):
- random.triangular(low=1, high=1, mode=11)
- # mode < low.
- with self.assertRaises(ValueError):
- random.triangular(mode=-1)
- with self.assertRaises(ValueError):
- random.triangular(low=1, high=10, mode=0)
- with self.assertRaises(ValueError):
- random.triangular(low=1, high=1, mode=0)
- # low > high
- with self.assertRaises(ValueError):
- random.triangular(low=5, high=2)
- with self.assertRaises(ValueError):
- random.triangular(low=5, high=2, mode=1)
- with self.assertRaises(ValueError):
- random.triangular(low=-2, high=-5)
-
- self.assertEqual(random.triangular(low=10, high=10), 10)
- self.assertEqual(random.triangular(low=10, high=10, mode=10), 10)
-
def test_jumpahead(self):
self.gen.seed()
state1 = self.gen.getstate()
@@ -570,7 +543,7 @@ class TestDistributions(unittest.TestCase):
for variate, args, expected in [
(g.uniform, (10.0, 10.0), 10.0),
(g.triangular, (10.0, 10.0), 10.0),
- (g.triangular, (10.0, 10.0, 10.0), 10.0),
+ #(g.triangular, (10.0, 10.0, 10.0), 10.0),
(g.expovariate, (float('inf'),), 0.0),
(g.vonmisesvariate, (3.0, float('inf')), 3.0),
(g.gauss, (10.0, 0.0), 10.0),
diff --git a/Misc/ACKS b/Misc/ACKS
index 9480f2d..4de44cc 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -907,7 +907,6 @@ Nick Seidenman
Žiga Seilnach
Yury Selivanov
Fred Sells
-Yuriy Senko
Jiwon Seo
Joakim Sernbrant
Roger Serwy
diff --git a/Misc/NEWS b/Misc/NEWS
index cb0dfc8..a5b78db 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -27,9 +27,6 @@ Library
- Issue #17656: Fix extraction of zip files with unicode member paths.
-- Issue #13355: Raise ValueError on random.triangular call with invalid params.
- Initial patch by Yuriy Senko.
-
- Issue #17666: Fix reading gzip files with an extra field.
- Issue #13150, #17512: sysconfig no longer parses the Makefile and config.h