diff options
author | seberg <sebastian@sipsolutions.net> | 2016-03-20 18:12:06 +0100 |
---|---|---|
committer | seberg <sebastian@sipsolutions.net> | 2016-03-20 18:12:06 +0100 |
commit | a52eef3ff24a78b347395b04ddafb08b6d6d8cf8 (patch) | |
tree | 1f7b37d5a1d3793bfdbbdd8b8c548c4db61ec608 /numpy/core/numeric.py | |
parent | 41ec9fc8b7ee9b710c3054b9e9409a7a1f6082f7 (diff) | |
parent | a073198864e18dab7fc78653a69175fa6c76e345 (diff) | |
download | numpy-a52eef3ff24a78b347395b04ddafb08b6d6d8cf8.tar.gz |
Merge pull request #7437 from anntzer/new-fill-dtype-behavior
MAINT: np.full now defaults to the filling value's dtype.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r-- | numpy/core/numeric.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 551d63a01..7f1206855 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -262,9 +262,8 @@ def full(shape, fill_value, dtype=None, order='C'): fill_value : scalar Fill value. dtype : data-type, optional - The desired data-type for the array, e.g., `np.int8`. Default - is `float`, but will change to `np.array(fill_value).dtype` in a - future release. + The desired data-type for the array The default, `None`, means + `np.array(fill_value).dtype`. order : {'C', 'F'}, optional Whether to store multidimensional data in C- or Fortran-contiguous (row- or column-wise) order in memory. @@ -289,16 +288,14 @@ def full(shape, fill_value, dtype=None, order='C'): >>> np.full((2, 2), np.inf) array([[ inf, inf], [ inf, inf]]) - >>> np.full((2, 2), 10, dtype=np.int) + >>> np.full((2, 2), 10) array([[10, 10], [10, 10]]) """ + if dtype is None: + dtype = array(fill_value).dtype a = empty(shape, dtype, order) - if dtype is None and array(fill_value).dtype != a.dtype: - warnings.warn( - "in the future, full({0}, {1!r}) will return an array of {2!r}". - format(shape, fill_value, array(fill_value).dtype), FutureWarning) multiarray.copyto(a, fill_value, casting='unsafe') return a |