diff options
author | Johannes Schönberger <jschoenberger@demuc.de> | 2013-06-30 12:31:39 +0200 |
---|---|---|
committer | Johannes Schönberger <jschoenberger@demuc.de> | 2013-06-30 12:32:46 +0200 |
commit | 70cb9e56f58331fae92f457705afca264a6c5b2c (patch) | |
tree | 8add5fbf32f2484b692bdc0306bef6e5319233f6 | |
parent | 7759766618a3d0db557d4483ebcc5b7a2d919c0a (diff) | |
download | numpy-70cb9e56f58331fae92f457705afca264a6c5b2c.tar.gz |
Rename filled, filled_like to full, full_like
-rw-r--r-- | doc/release/1.8.0-notes.rst | 2 | ||||
-rw-r--r-- | numpy/core/numeric.py | 26 | ||||
-rw-r--r-- | numpy/core/tests/test_numeric.py | 16 |
3 files changed, 22 insertions, 22 deletions
diff --git a/doc/release/1.8.0-notes.rst b/doc/release/1.8.0-notes.rst index e921e69f6..bea3b56bd 100644 --- a/doc/release/1.8.0-notes.rst +++ b/doc/release/1.8.0-notes.rst @@ -117,7 +117,7 @@ It is now possible to use `np.newaxis`/`None` together with index arrays instead of only in simple indices. This means that ``array[np.newaxis, [0, 1]]`` will now work as expected. -New functions `filled` and `filled_like` +New functions `full` and `full_like` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ New convenience functions to create arrays filled with a specific value; diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 604ff2dd6..12b23cb83 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -40,7 +40,7 @@ __all__ = ['newaxis', 'ndarray', 'flatiter', 'nditer', 'nested_iters', 'ufunc', 'Inf', 'inf', 'infty', 'Infinity', 'nan', 'NaN', 'False_', 'True_', 'bitwise_not', 'CLIP', 'RAISE', 'WRAP', 'MAXDIMS', 'BUFSIZE', 'ALLOW_THREADS', - 'ComplexWarning', 'may_share_memory', 'filled', 'filled_like'] + 'ComplexWarning', 'may_share_memory', 'full', 'full_like'] if sys.version_info[0] < 3: __all__.extend(['getbuffer', 'newbuffer']) @@ -237,7 +237,7 @@ def ones_like(a, dtype=None, order='K', subok=True): multiarray.copyto(res, 1, casting='unsafe') return res -def filled(shape, fill_value, dtype=None, order='C'): +def full(shape, fill_value, dtype=None, order='C'): """ Return a new array of given shape and type, filled with `fill_value`. @@ -264,17 +264,17 @@ def filled(shape, fill_value, dtype=None, order='C'): zeros_like : Return an array of zeros with shape and type of input. ones_like : Return an array of ones with shape and type of input. empty_like : Return an empty array with shape and type of input. - filled_like : Fill an array with shape and type of input. + full_like : Fill an array with shape and type of input. zeros : Return a new array setting values to zero. ones : Return a new array setting values to one. empty : Return a new uninitialized array. Examples -------- - >>> np.filled((2, 2), np.inf) + >>> np.full((2, 2), np.inf) array([[ inf, inf], [ inf, inf]]) - >>> np.filled((2, 2), 10, dtype=np.int) + >>> np.full((2, 2), 10, dtype=np.int) array([[10, 10], [10, 10]]) @@ -283,9 +283,9 @@ def filled(shape, fill_value, dtype=None, order='C'): multiarray.copyto(a, fill_value, casting='unsafe') return a -def filled_like(a, fill_value, dtype=None, order='K', subok=True): +def full_like(a, fill_value, dtype=None, order='K', subok=True): """ - Return a filled array with the same shape and type as a given array. + Return a full array with the same shape and type as a given array. Parameters ---------- @@ -319,22 +319,22 @@ def filled_like(a, fill_value, dtype=None, order='K', subok=True): zeros : Return a new array setting values to zero. ones : Return a new array setting values to one. empty : Return a new uninitialized array. - filled : Fill a new array. + full : Fill a new array. Examples -------- >>> x = np.arange(6, dtype=np.int) - >>> np.filled_like(x, 1) + >>> np.full_like(x, 1) array([1, 1, 1, 1, 1, 1]) - >>> np.filled_like(x, 0.1) + >>> np.full_like(x, 0.1) array([0, 0, 0, 0, 0, 0]) - >>> np.filled_like(x, 0.1, dtype=np.double) + >>> np.full_like(x, 0.1, dtype=np.double) array([ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]) - >>> np.filled_like(x, np.nan, dtype=np.double) + >>> np.full_like(x, np.nan, dtype=np.double) array([ nan, nan, nan, nan, nan, nan]) >>> y = np.arange(6, dtype=np.double) - >>> np.filled_like(y, 0.1) + >>> np.full_like(y, 0.1) array([ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]) """ diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py index f0cb1c1a5..e37d8ab33 100644 --- a/numpy/core/tests/test_numeric.py +++ b/numpy/core/tests/test_numeric.py @@ -1379,12 +1379,12 @@ class TestCreationFuncs(TestCase): self.check_function(np.empty) def test_filled(self): - self.check_function(np.filled, 0) - self.check_function(np.filled, 1) + self.check_function(np.full, 0) + self.check_function(np.full, 1) class TestLikeFuncs(TestCase): - '''Test ones_like, zeros_like, empty_like and filled_like''' + '''Test ones_like, zeros_like, empty_like and full_like''' def setUp(self): self.data = [ @@ -1494,11 +1494,11 @@ class TestLikeFuncs(TestCase): self.check_like_function(np.empty_like, None) def test_filled_like(self): - self.check_like_function(np.filled_like, 0, True) - self.check_like_function(np.filled_like, 1, True) - self.check_like_function(np.filled_like, 1000, True) - self.check_like_function(np.filled_like, 123.456, True) - self.check_like_function(np.filled_like, np.inf, True) + self.check_like_function(np.full_like, 0, True) + self.check_like_function(np.full_like, 1, True) + self.check_like_function(np.full_like, 1000, True) + self.check_like_function(np.full_like, 123.456, True) + self.check_like_function(np.full_like, np.inf, True) class _TestCorrelate(TestCase): def _setup(self, dt): |