]> granicus.if.org Git - python/commitdiff
Revert changes for #13355 by request from Raymond Hettinger
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Sat, 13 Apr 2013 15:00:04 +0000 (18:00 +0300)
committerAndrew Svetlov <andrew.svetlov@gmail.com>
Sat, 13 Apr 2013 15:00:04 +0000 (18:00 +0300)
Lib/random.py
Lib/test/test_random.py
Misc/ACKS
Misc/NEWS

index 11a0606e9ce2fb84729de1473f3e560f51e099b7..7d8d4f3a408dfd2e1c49a4a454cc706408697c74 100644 (file)
@@ -341,16 +341,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:
index 34e144cd3508be5db9417e6babb20e6b44c05b23..c3ab7d23216730d69c6771744d4d92675f59a11d 100644 (file)
@@ -46,36 +46,6 @@ class TestBasicOps(unittest.TestCase):
         self.assertRaises(TypeError, self.gen.seed, 1, 2, 3, 4)
         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_choice(self):
         choice = self.gen.choice
         with self.assertRaises(IndexError):
@@ -519,7 +489,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),
index fb0ff727d7c07170fd1f20d165bf795b5e1d8963..7382dec9f495d2b5816a165547d76d5b8eaa5e4d 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1088,7 +1088,6 @@ Nick Seidenman
 Žiga Seilnacht
 Yury Selivanov
 Fred Sells
-Yuriy Senko
 Jiwon Seo
 Iñigo Serna
 Joakim Sernbrant
index 94a3ed32e9af4f05f3a3884c3bd76e774dd85bc2..e04324fce95587c4787ff5f1b5ccec800d00f7d4 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -26,9 +26,6 @@ Core and Builtins
 Library
 -------
 
-- Issue #13355: Raise ValueError on random.triangular call with invalid params.
-  Initial patch by Yuriy Senko.
-
 - Issue #16658: add missing return to HTTPConnection.send()
   Patch by Jeff Knupp.