8000 Merge pull request #6382 from anntzer/fill-default-dtype-futurewarning · numpy/numpy@807e01c · GitHub
[go: up one dir, main page]

Skip to content

Commit 807e01c

Browse files
committed
Merge pull request #6382 from anntzer/fill-default-dtype-futurewarning
FutureWarning for np.full(..., non-float).
2 parents 986a98c + 649d19f commit 807e01c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

numpy/core/numeric.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,9 @@ def full(shape, fill_value, dtype=None, order='C'):
258258
fill_value : scalar
259259
Fill value.
260260
dtype : data-type, optional
261-
The desired data-type for the array, e.g., `numpy.int8`. Default is
262-
is chosen as `np.array(fill_value).dtype`.
261+
The desired data-type for the array, e.g., `np.int8`. Default
262+
is `float`, but will change to `np.array(fill_value).dtype` in a
263+
future release.
263264
order : {'C', 'F'}, optional
264265
Whether to store multidimensional data in C- or Fortran-contiguous
265266
(row- or column-wise) order in memory.
@@ -290,6 +291,10 @@ def full(shape, fill_value, dtype=None, order='C'):
290291
291292
"""
292293
a = empty(shape, dtype, order)
294+
if array(fill_value).dtype != a.dtype:
295+
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)
293298
multiarray.copyto(a, fill_value, casting='unsafe')
294299
return a
295300

0 commit comments

Comments
 (0)
0