Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
75f1fc27
Commit
75f1fc27
authored
Apr 13, 2013
by
Andrew Svetlov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert changes for #13355 by request from Raymond Hettinger
parent
f794b143
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 addition
and
42 deletions
+1
-42
Lib/random.py
Lib/random.py
+0
-10
Lib/test/test_random.py
Lib/test/test_random.py
+1
-28
Misc/ACKS
Misc/ACKS
+0
-1
Misc/NEWS
Misc/NEWS
+0
-3
No files found.
Lib/random.py
View file @
75f1fc27
...
...
@@ -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
:
...
...
Lib/test/test_random.py
View file @
75f1fc27
...
...
@@ -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
),
...
...
Misc/ACKS
View file @
75f1fc27
...
...
@@ -907,7 +907,6 @@ Nick Seidenman
Žiga Seilnach
Yury Selivanov
Fred Sells
Yuriy Senko
Jiwon Seo
Joakim Sernbrant
Roger Serwy
...
...
Misc/NEWS
View file @
75f1fc27
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment