summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-12-02 05:07:35 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-12-02 05:07:35 +0000
commit3a93adce6609cd3499d85c5f2b9dc38d3d1255c7 (patch)
treec965535dae00b60b48306a6d69b8ab9becac113d /numpy/core/numeric.py
parent921fa088183b86dbaeb35a9c9af17980e7708a54 (diff)
downloadnumpy-3a93adce6609cd3499d85c5f2b9dc38d3d1255c7.tar.gz
Fix warnings found by Intel compiler due to unused variables that were set. Make ones work for compound types.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 5b1a7dcd0..0905b3939 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -587,15 +587,29 @@ def load(file):
# These are all essentially abbreviations
# These might wind up in a special abbreviations module
+def _maketup(descr, val):
+ dt = dtype(descr)
+ # Place val in all scalar tuples:
+ fields = dt.fields
+ if fields is None:
+ return val
+ else:
+ res = [_maketup(fields[name][0],val) for name in dt.names]
+ return tuple(res)
+
def ones(shape, dtype=None, order='C'):
"""Returns an array of the given dimensions which is initialized to all
ones.
"""
a = empty(shape, dtype, order)
- a.fill(1)
- # Above is faster now after addition of fast loops.
- #a = zeros(shape, dtype, order)
- #a+=1
+ 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)
return a
def identity(n, dtype=None):