summaryrefslogtreecommitdiff
path: root/scipy/base/ma.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2005-12-31 21:31:00 +0000
committerTravis Oliphant <oliphant@enthought.com>2005-12-31 21:31:00 +0000
commitcd9c8d62c5c16452c29c622e2bb24a2cf26e1da3 (patch)
tree59572334b556db5335609f3a37deb85f1e3c5451 /scipy/base/ma.py
parentee794463ce58609eb14c8091b01c4f5f24713b04 (diff)
downloadnumpy-cd9c8d62c5c16452c29c622e2bb24a2cf26e1da3.tar.gz
Added 1-d indexing speed-ups by going through the array iterator when fancy-indexing is needed. Also added bug-fixes to ma.py from Sourceforge.
Diffstat (limited to 'scipy/base/ma.py')
-rw-r--r--scipy/base/ma.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/scipy/base/ma.py b/scipy/base/ma.py
index 3b8de05a3..a88d3cb4f 100644
--- a/scipy/base/ma.py
+++ b/scipy/base/ma.py
@@ -1436,7 +1436,7 @@ arange = arrayrange
def fromstring (s, t):
"Construct a masked array from a string. Result will have no mask."
- return masked_array(umath.fromstring(s, t))
+ return masked_array(numeric.fromstring(s, t))
def left_shift (a, n):
"Left shift n bits"
@@ -1764,7 +1764,7 @@ def masked_outside(x, v1, v2, copy=1):
def reshape (a, *newshape):
"Copy of a with a new shape."
m = getmask(a)
- d = umath.reshape(filled(a), *newshape)
+ d = filled(a).reshape(*newshape)
if m is None:
return masked_array(d)
else:
@@ -1815,6 +1815,32 @@ def transpose(a, axes=None):
return masked_array(numeric.transpose(d, axes),
mask = numeric.transpose(m, axes))
+
+def put(a, indices, values):
+ """put(a, indices, values) sets storage-indexed locations to corresponding values.
+
+ Values and indices are filled if necessary.
+
+ """
+ d = a.raw_data()
+ ind = filled(indices)
+ v = filled(values)
+ numeric.put (d, ind, v)
+ m = getmask(a)
+ if m is not None:
+ a.unshare_mask()
+ numeric.put(a.raw_mask(), ind, 0)
+
+def putmask(a, mask, values):
+ "putmask(a, mask, values) sets a where mask is true."
+ if mask is None:
+ return
+ numeric.putmask(a.raw_data(), mask, values)
+ m = getmask(a)
+ if m is None: return
+ a.unshare_mask()
+ numeric.putmask(a.raw_mask(), mask, 0)
+
def innerproduct(a,b):
"""innerproduct(a,b) returns the dot product of two arrays, which has
shape a.shape[:-1] + b.shape[:-1] with elements computed by summing the