diff options
author | Nathaniel J. Smith <njs@pobox.com> | 2012-05-11 14:31:50 +0100 |
---|---|---|
committer | Nathaniel J. Smith <njs@pobox.com> | 2012-06-16 10:45:38 +0100 |
commit | b272bc605ce7784be5b3edb13ad7afe22b04e71f (patch) | |
tree | 40fc10c60fd1b48d94be48a80e7cfc98525bd6e7 /doc/source/reference/c-api.array.rst | |
parent | 1b6582d98c58afd977a69ac49f7e8e0d08a800b8 (diff) | |
download | numpy-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 'doc/source/reference/c-api.array.rst')
-rw-r--r-- | doc/source/reference/c-api.array.rst | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/doc/source/reference/c-api.array.rst b/doc/source/reference/c-api.array.rst index 8eedc689a..8736cbc3f 100644 --- a/doc/source/reference/c-api.array.rst +++ b/doc/source/reference/c-api.array.rst @@ -92,40 +92,6 @@ sub-types). A synonym for PyArray_DESCR, named to be consistent with the 'dtype' usage within Python. -.. cfunction:: npy_bool PyArray_HASMASKNA(PyArrayObject* arr) - - .. versionadded:: 1.7 - - Returns true if the array has an NA-mask, false otherwise. - -.. cfunction:: PyArray_Descr *PyArray_MASKNA_DTYPE(PyArrayObject* arr) - - .. versionadded:: 1.7 - - Returns a borrowed reference to the dtype property for the NA mask - of the array, or NULL if the array has no NA mask. This function does - not raise an exception when it returns NULL, it is simply returning - the appropriate field. - -.. cfunction:: char *PyArray_MASKNA_DATA(PyArrayObject* arr) - - .. versionadded:: 1.7 - - Returns a pointer to the raw data for the NA mask of the array, - or NULL if the array has no NA mask. This function does - not raise an exception when it returns NULL, it is simply returning - the appropriate field. - -.. cfunction:: npy_intp *PyArray_MASKNA_STRIDES(PyArrayObject* arr) - - .. versionadded:: 1.7 - - Returns a pointer to strides of the NA mask of the array, If the - array has no NA mask, the values contained in the array will be - invalid. The shape of the NA mask is identical to the shape of the - array itself, so the number of strides is always the same as the - number of array dimensions. - .. cfunction:: void PyArray_ENABLEFLAGS(PyArrayObject* arr, int flags) .. versionadded:: 1.7 @@ -254,11 +220,6 @@ From scratch provided *dims* and *strides* are copied into newly allocated dimension and strides arrays for the new array object. - Because the flags are ignored when *data* is NULL, you cannot - create a new array from scratch with an NA mask. If one is desired, - call the function :cfunc:`PyArray_AllocateMaskNA` after the array - is created. - .. cfunction:: PyObject* PyArray_NewLikeArray(PyArrayObject* prototype, NPY_ORDER order, PyArray_Descr* descr, int subok) .. versionadded:: 1.6 @@ -281,11 +242,6 @@ From scratch *prototype* to create the new array, otherwise it will create a base-class array. - The newly allocated array does not have an NA mask even if the - *prototype* provided does. If an NA mask is desired in the array, - call the function :cfunc:`PyArray_AllocateMaskNA` after the array - is created. - .. cfunction:: PyObject* PyArray_New(PyTypeObject* subtype, int nd, npy_intp* dims, int type_num, npy_intp* strides, void* data, int itemsize, int flags, PyObject* obj) This is similar to :cfunc:`PyArray_DescrNew` (...) except you @@ -475,31 +431,6 @@ From other objects with, then an error is raised. If *op* is not already an array, then this flag has no effect. - .. cvar:: NPY_ARRAY_MASKNA - - .. versionadded:: 1.7 - - Make sure the array has an NA mask associated with its data. - - .. cvar:: NPY_ARRAY_OWNMASKNA - - .. versionadded:: 1.7 - - Make sure the array has an NA mask which it owns - associated with its data. - - .. cvar:: NPY_ARRAY_ALLOWNA - - .. versionadded:: 1.7 - - To prevent simple errors from slipping in, arrays with NA - masks are not permitted to pass through by default. Instead - an exception is raised indicating the operation doesn't support - NA masks yet. In order to enable NA mask support, this flag - must be passed in to allow the NA mask through, signalling that - the later code is written appropriately to handle NA mask - semantics. - .. cvar:: NPY_ARRAY_BEHAVED :cdata:`NPY_ARRAY_ALIGNED` \| :cdata:`NPY_ARRAY_WRITEABLE` @@ -1415,24 +1346,6 @@ or :cdata:`NPY_ARRAY_F_CONTIGUOUS` can be determined by the ``strides``, would have returned an error because :cdata:`NPY_ARRAY_UPDATEIFCOPY` would not have been possible. -.. cvar:: NPY_ARRAY_MASKNA - - If this flag is enabled, the array has an NA mask associated with - the data. C code which interacts with the NA mask must follow - specific semantic rules about when to overwrite data and when not - to. The mask can be accessed through the functions - :cfunc:`PyArray_MASKNA_DTYPE`, :cfunc:`PyArray_MASKNA_DATA`, and - :cfunc:`PyArray_MASKNA_STRIDES`. - -.. cvar:: NPY_ARRAY_OWNMASKNA - - If this flag is enabled, the array owns its own NA mask. If it is not - enabled, the NA mask is a view into a different array's NA mask. - - In order to ensure that an array owns its own NA mask, you can - call :cfunc:`PyArray_AllocateMaskNA` with the parameter *ownmaskna* - set to 1. - :cfunc:`PyArray_UpdateFlags` (obj, flags) will update the ``obj->flags`` for ``flags`` which can be any of :cdata:`NPY_ARRAY_C_CONTIGUOUS`, :cdata:`NPY_ARRAY_F_CONTIGUOUS`, :cdata:`NPY_ARRAY_ALIGNED`, or @@ -2541,9 +2454,6 @@ Array Scalars if so, returns the appropriate array scalar. It should be used whenever 0-dimensional arrays could be returned to Python. - If *arr* is a 0-dimensional NA-masked array with its value hidden, - an instance of :ctype:`NpyNA *` is returned. - .. cfunction:: PyObject* PyArray_Scalar(void* data, PyArray_Descr* dtype, PyObject* itemsize) Return an array scalar object of the given enumerated *typenum* @@ -2756,19 +2666,6 @@ to. . No matter what is returned, you must DECREF the object returned by this routine in *address* when you are done with it. - If the input is an array with NA support, this will either raise - an error if it contains any NAs, or will make a copy of the array - without NA support if it does not contain any NAs. Use the function - :cfunc:`PyArray_AllowNAConverter` to support NA-arrays directly - and more efficiently. - -.. cfunction:: int PyArray_AllowConverter(PyObject* obj, PyObject** address) - - This is the same as :cfunc:`PyArray_Converter`, but allows arrays - with NA support to pass through untouched. This function was created - so that the existing converter could raise errors appropriately - for functions which have not been updated with NA support - .. cfunction:: int PyArray_OutputConverter(PyObject* obj, PyArrayObject** address) This is a default converter for output arrays given to @@ -2777,17 +2674,6 @@ to. *obj*) is TRUE then it is returned in *\*address* without incrementing its reference count. - If the output is an array with NA support, this will raise an error. - Use the function :cfunc:`PyArray_OutputAllowNAConverter` to support - NA-arrays directly. - -.. cfunction:: int PyArray_OutputAllowNAConverter(PyObject* obj, PyArrayObject** address) - - This is the same as :cfunc:`PyArray_OutputConverter`, but allows arrays - with NA support to pass through. This function was created - so that the existing output converter could raise errors appropriately - for functions which have not been updated with NA support - .. cfunction:: int PyArray_IntpConverter(PyObject* obj, PyArray_Dims* seq) Convert any Python sequence, *obj*, smaller than :cdata:`NPY_MAXDIMS` |