diff options
author | Mark Wiebe <mwiebe@enthought.com> | 2011-07-08 18:11:24 -0500 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-07-08 19:38:25 -0600 |
commit | 76f9e50c9e40967d9a41cb6a630b2448af9e8687 (patch) | |
tree | ddcf89bcc655e950be69b58bbaeb66396b3b2494 /numpy/core/numeric.py | |
parent | 75a2c03a0836b9e094bfad4c02c643901d17c593 (diff) | |
download | numpy-76f9e50c9e40967d9a41cb6a630b2448af9e8687.tar.gz |
ENH: Use np.copyto instead of np.fill in some places
This should allow one to create struct dtype arrays with np.ones
and np.zeros_like.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r-- | numpy/core/numeric.py | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index a28b6f3c4..80db6573e 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -114,7 +114,7 @@ def zeros_like(a, dtype=None, order='K', subok=True): """ res = empty_like(a, dtype=dtype, order=order, subok=subok) - res.fill(0) + multiarray.copyto(res, 0, casting='unsafe') return res # end Fernando's utilities @@ -1818,14 +1818,7 @@ def ones(shape, dtype=None, order='C'): """ a = empty(shape, dtype, order) - try: - a.fill(1) - # Above is faster now after addition of fast loops. - #a = zeros(shape, dtype, order) - #a+=1 - except TypeError: - obj = _maketup(dtype, 1) - a.fill(obj) + multiarray.copyto(a, 1, casting='unsafe') return a def identity(n, dtype=None): |