summaryrefslogtreecommitdiff
path: root/numpy/core/function_base.py
diff options
context:
space:
mode:
authorNathaniel J. Smith <njs@pobox.com>2012-05-11 14:31:50 +0100
committerNathaniel J. Smith <njs@pobox.com>2012-06-16 10:45:38 +0100
commitb272bc605ce7784be5b3edb13ad7afe22b04e71f (patch)
tree40fc10c60fd1b48d94be48a80e7cfc98525bd6e7 /numpy/core/function_base.py
parent1b6582d98c58afd977a69ac49f7e8e0d08a800b8 (diff)
downloadnumpy-b272bc605ce7784be5b3edb13ad7afe22b04e71f.tar.gz
Remove maskna API from ndarray, and all (and only) the code supporting it
The original masked-NA-NEP branch contained a large number of changes in addition to the core NA support. For example: - ufunc.__call__ support for where= argument - nditer support for arbitrary masks (in support of where=) - ufunc.reduce support for simultaneous reduction over multiple axes - a new "array assignment API" - ndarray.diagonal() returning a view in all cases - bug-fixes in __array_priority__ handling - datetime test changes etc. There's no consensus yet on what should be done with the maskna-related part of this branch, but the rest is generally useful and uncontroversial, so the goal of this branch is to identify exactly which code changes are involved in maskna support. The basic strategy used to create this patch was: - Remove the new masking-related fields from ndarray, so no arrays are masked - Go through and remove all the code that this makes dead/inaccessible/irrelevant, in a largely mechanical fashion. So for example, if I saw 'if (PyArray_HASMASK(a)) { ... }' then that whole block was obviously just dead code if no arrays have masks, and I removed it. Likewise for function arguments like skipna that are useless if there aren't any NAs to skip. This changed the signature of a number of functions that were newly exposed in the numpy public API. I've removed all such functions from the public API, since releasing them with the NA-less signature in 1.7 would create pointless compatibility hassles later if and when we add back the NA-related functionality. Most such functions are removed by this commit; the exception is PyArray_ReduceWrapper, which requires more extensive surgery, and will be handled in followup commits. I also removed the new ndarray.setasflat method. Reason: a comment noted that the only reason this was added was to allow easier testing of one branch of PyArray_CopyAsFlat. That branch is now the main branch, so that isn't an issue. Nonetheless this function is arguably useful, so perhaps it should have remained, but I judged that since numpy's API is already hairier than we would like, it's not a good idea to add extra hair "just in case". (Also AFAICT the test for this method in test_maskna was actually incorrect, as noted here: https://github.com/njsmith/numpyNEP/blob/master/numpyNEP.py so I'm not confident that it ever worked in master, though I haven't had a chance to follow-up on this.) I also removed numpy.count_reduce_items, since without skipna it became trivial. I believe that these are the only exceptions to the "remove dead code" strategy.
Diffstat (limited to 'numpy/core/function_base.py')
-rw-r--r--numpy/core/function_base.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/numpy/core/function_base.py b/numpy/core/function_base.py
index 3e919c761..b2f9dc70c 100644
--- a/numpy/core/function_base.py
+++ b/numpy/core/function_base.py
@@ -3,7 +3,7 @@ __all__ = ['logspace', 'linspace']
import numeric as _nx
from numeric import array
-def linspace(start, stop, num=50, endpoint=True, retstep=False, maskna=False):
+def linspace(start, stop, num=50, endpoint=True, retstep=False):
"""
Return evenly spaced numbers over a specified interval.
@@ -29,8 +29,6 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False, maskna=False):
retstep : bool, optional
If True, return (`samples`, `step`), where `step` is the spacing
between samples.
- maskna : boolean
- If this is true, the returned array will have an NA mask.
Returns
-------
@@ -75,22 +73,22 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False, maskna=False):
"""
num = int(num)
if num <= 0:
- return array([], float, maskna=maskna)
+ return array([], float)
if endpoint:
if num == 1:
- return array([float(start)], maskna=maskna)
+ return array([float(start)])
step = (stop-start)/float((num-1))
- y = _nx.arange(0, num, maskna=maskna) * step + start
+ y = _nx.arange(0, num) * step + start
y[-1] = stop
else:
step = (stop-start)/float(num)
- y = _nx.arange(0, num, maskna=maskna) * step + start
+ y = _nx.arange(0, num) * step + start
if retstep:
return y, step
else:
return y
-def logspace(start,stop,num=50,endpoint=True,base=10.0, maskna=False):
+def logspace(start,stop,num=50,endpoint=True,base=10.0):
"""
Return numbers spaced evenly on a log scale.
@@ -116,8 +114,6 @@ def logspace(start,stop,num=50,endpoint=True,base=10.0, maskna=False):
The base of the log space. The step size between the elements in
``ln(samples) / ln(base)`` (or ``log_base(samples)``) is uniform.
Default is 10.0.
- maskna : boolean
- If this is true, the returned array will have an NA mask.
Returns
-------
@@ -166,6 +162,6 @@ def logspace(start,stop,num=50,endpoint=True,base=10.0, maskna=False):
>>> plt.show()
"""
- y = linspace(start,stop,num=num,endpoint=endpoint,maskna=maskna)
+ y = linspace(start,stop,num=num,endpoint=endpoint)
return _nx.power(base,y)