summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2011-08-27 21:46:08 -0600
committerCharles Harris <charlesr.harris@gmail.com>2011-08-27 21:46:08 -0600
commit9ecd91b7bf8c77d696ec9856ba10896d8f60309a (patch)
tree9884131ece5eada06212538c591965bf5928afa2 /numpy/lib/function_base.py
parentaa55ba7437fbe6b8772a360a641b5aa7d3e669e0 (diff)
parent10fac981763e87f949bed15c66127fc380fa9b27 (diff)
downloadnumpy-9ecd91b7bf8c77d696ec9856ba10896d8f60309a.tar.gz
Merge branch 'pull-141'
* pull-141: (167 commits) ENH: missingdata: Make PyArray_Converter and PyArray_OutputConverter safer for legacy code DOC: missingdata: Add a mention of the design NEP, and masks vs bitpatterns DOC: missingdata: Updates from pull request feedback DOC: missingdata: Updates based on pull request feedback ENH: nditer: Change the Python nditer exposure to automatically add NPY_ITER_USE_MASKNA ENH: missingdata: Make comparisons with NA return NA(dtype='bool') BLD: core: onefile build fix and Python3 compatibility change DOC: Mention the update to np.all and np.any in the release notes TST: dtype: Adjust void dtype test to pass without raising a zero-size exception STY: Remove trailing whitespace TST: missingdata: Write some tests for the np.any and np.all NA behavior ENH: missingdata: Make numpy.all follow the NA && False == False rule ENH: missingdata: Make numpy.all follow the NA || True == True rule DOC: missingdata: Also show what assigning a non-NA value does in each case DOC: missingdata: Add introductory documentation for NA-masked arrays ENH: core: Rename PyArrayObject_fieldaccess to PyArrayObject_fields DOC: missingdata: Some tweaks to the NA mask documentation DOC: missingdata: Add example of a C-API function supporting NA masks DOC: missingdata: Documenting C API for NA-masked arrays ENH: missingdata: Finish adding C-API access to the NpyNA object ...
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index caef5c709..b269d98a1 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -778,7 +778,7 @@ def select(condlist, choicelist, default=0):
S = S*ones(asarray(pfac).shape, S.dtype)
return choose(S, tuple(choicelist))
-def copy(a):
+def copy(a, order='C', maskna=None):
"""
Return an array copy of the given object.
@@ -786,6 +786,15 @@ def copy(a):
----------
a : array_like
Input data.
+ order : {'C', 'F', 'A', 'K'}, optional
+ Controls the memory layout of the copy. 'C' means C-order,
+ 'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous,
+ 'C' otherwise. 'K' means match the layout of `a` as closely
+ as possible.
+ maskna : bool, optional
+ If specifies, forces the copy to have or to not have an
+ NA mask. This is a way to remove an NA mask from an array
+ while making a copy.
Returns
-------
@@ -815,7 +824,7 @@ def copy(a):
False
"""
- return array(a, copy=True)
+ return array(a, order=order, copy=True, maskna=maskna)
# Basic operations
@@ -3317,6 +3326,7 @@ def delete(arr, obj, axis=None):
"invalid entry")
newshape[axis]-=1;
new = empty(newshape, arr.dtype, arr.flags.fnc)
+ new.flags.maskna = arr.flags.maskna
slobj[axis] = slice(None, obj)
new[slobj] = arr[slobj]
slobj[axis] = slice(obj,None)
@@ -3333,6 +3343,7 @@ def delete(arr, obj, axis=None):
return arr.copy()
newshape[axis] -= numtodel
new = empty(newshape, arr.dtype, arr.flags.fnc)
+ new.flags.maskna = arr.flags.maskna
# copy initial chunk
if start == 0:
pass
@@ -3464,6 +3475,7 @@ def insert(arr, obj, values, axis=None):
"in dimension %d" % (obj, N, axis))
newshape[axis] += 1;
new = empty(newshape, arr.dtype, arr.flags.fnc)
+ new.flags.maskna = arr.flags.maskna
slobj[axis] = slice(None, obj)
new[slobj] = arr[slobj]
slobj[axis] = obj
@@ -3490,6 +3502,7 @@ def insert(arr, obj, values, axis=None):
index2 = setdiff1d(arange(numnew+N),index1)
newshape[axis] += numnew
new = empty(newshape, arr.dtype, arr.flags.fnc)
+ new.flags.maskna = arr.flags.maskna
slobj2 = [slice(None)]*ndim
slobj[axis] = index1
slobj2[axis] = index2