8000 fixes from review · numpy/numpy@9013b0f · GitHub
[go: up one dir, main page]

Skip to content

Commit 9013b0f

Browse files
committed
fixes from review
1 parent 95dada6 commit 9013b0f

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

doc/release/1.16.0-notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Improvements
3939
Even when no elements needed to be drawn, ``np.random.randint`` and
4040
``np.random.choice`` raised an error when the arguments described an empty
4141
distribution. This has been fixed so that e.g.
42-
``np.random.choice([],0) == np.array([],dtype=float64)``.
42+
``np.random.choice([], 0) == np.array([], dtype=float64)``.
4343

4444
Changes
4545
=======

numpy/random/mtrand/mtrand.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ cdef class RandomState:
11221122
else:
11231123
pop_size = a.shape[0]
11241124
if pop_size is 0 and np.prod(size) != 0:
1125-
raise ValueError("a cannot be empty unless no samples are taken")
1125+
raise ValueError("'a' cannot be empty unless no samples are taken")
11261126

11271127
if p is not None:
11281128
d = len(p)

numpy/random/tests/test_random.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,11 @@ def test_choice_return_shape(self):
441441
assert_equal(np.random.choice(np.arange(6), s, replace=True).shape, s)
442442

443443
# Check zero-size
444-
assert_equal(np.random.randint(0,0,(3,0,4)).shape, (3,0,4))
445-
assert_equal(np.random.randint(0,-10,0).shape, (0,))
446-
assert_equal(np.random.choice(0,0).shape, (0,))
447-
assert_equal(np.random.choice([],(0,)).shape, (0,))
444+
assert_equal(np.random.randint(0, 0, size=(3, 0, 4)).shape, (3, 0, 4))
445+
assert_equal(np.random.randint(0, -10, size=0).shape, (0,))
446+
assert_equal(np.random.randint(10, 10, size=0).shape, (0,))
447+
assert_equal(np.random.choice(0, size=0).shape, (0,))
448+
assert_equal(np.random.choice([], size=(0,)).shape, (0,))
448449
assert_equal(np.random.choice(['a', 'b'], size=(3, 0, 4)).shape, (3, 0, 4))
449450
assert_raises(ValueError, np.random.choice, [], 10)
450451

0 commit comments

Comments
 (0)
0