8000 DEP: Remove warning for `full` when dtype is set. · anntzer/numpy@7978f3d · GitHub
[go: up one dir, main page]

Skip to content

Commit 7978f3d

Browse files
committed
DEP: Remove warning for full when dtype is set.
See @rkern's comment in numpy#6382.
1 parent 2b7eefb commit 7978f3d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

numpy/core/numeric.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,10 @@ def full(shape, fill_value, dtype=None, order='C'):
291291
292292
"""
293293
a = empty(shape, dtype, order)
294-
if array(fill_value).dtype != a.dtype:
294+
if dtype is None and array(fill_value).dtype != a.dtype:
295295
warnings.warn(
296-
"in the future, full(..., {0!r}) will return an array of {1!r}".
297-
format(fill_value, array(fill_value).dtype), FutureWarning)
296+
"in the future, full({0}, {1!r}) will return an array of {2!r}".
297+
format(shape, fill_value, array(fill_value).dtype), FutureWarning)
298298
multiarray.copyto(a, fill_value, casting='unsafe')
299299
return a
300300

numpy/core/tests/test_deprecations.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
import warnings
1111

1212
import numpy as np
13-
from numpy.testing import (run_module_suite, assert_raises,
14-
assert_warns, assert_array_equal, assert_)
13+
from numpy.testing import (
14+
run_module_suite, assert_raises, assert_warns, assert_no_warnings,
15+
assert_array_equal, assert_)
1516

1617

1718
class _DeprecationTestCase(object):
@@ -382,6 +383,7 @@ class TestFullDefaultDtype:
382383
def test_full_default_dtype(self):
383384
assert_warns(FutureWarning, np.full, 1, 1)
384385
assert_warns(FutureWarning, np.full, 1, None)
386+
assert_no_warnings(np.full, 1, 1, float)
385387

386388

387389
if __name__ == "__main__":

0 commit comments

Comments
 (0)
0