[Numpy-discussion] Masked Arrays in NumPy 1.x

Charles R Harris charlesr.harris at gmail.com
Tue Apr 24 16:03:19 EDT 2012


2012/4/24 Frédéric Bastien <nouiz at nouiz.org>

> Hi,
>
> I finished reading the doc I listed in the other thread. As the NA
> stuff will be marked as Experimental in numpy 1.7, why not define a
> new macro like NPY_NA_VERSION that will give the version of the NA
> C-api? That way, people will be able to detect if there is change in
> the c-api of NA when they write it. So this will allow to break this
> interface more easily. We would just need to make a big warning to do
> this check it.
>
>
This sounds like a good thing to do.


> The current NPY_VERSION and NPY_FEATURE_VERSION macro don't allow
> removing feature. Probably a function like PyArray_GetNACVersion would
> be useful too.[1]
>
> Continuing on my previous post, old code need to be changed to don't
> accept NA inputs.  With the current trunk, this can be done like this:
>
> PyObject* an_input = ....;
>
> if (!PyArray_Check(an_input) {
>    PyErr_SetString(PyExc_ValueError, "expected an ndarray");
>    %(fail)s
> }
>
> if (NPY_FEATURE_VERSION >= 0x00000008){
>   if(PyArray_HasNASupport((PyArrayObject*) an_input )){
>          PyErr_SetString(PyExc_ValueError, "masked array are not
> supported by this function");
>          %(fail)s
>   }
> }
>
> In the 1.6.1 release, NPY_FEATURE_VERSION had value 0x00000007. This
> value wasn't changed in the trunk. I suppose it will be raised to
> 0x00000008 for numpy 1.7.
>
> Can we suppose that old code check input with PyArray_Check()? I think
> so, but it would be really helpful if  people that are here for longer
> them me can confirm/deny this?
>
>
Should be 6 in 1.6

# Binary compatibility version number. This number is increased whenever the
# C-API is changed such that binary compatibility is broken, i.e. whenever a
# recompile of extension modules is needed.
C_ABI_VERSION = 0x01000009

# Minor API version.  This number is increased whenever a change is made to
the
# C-API -- whether it breaks binary compatibility or not.  Some changes,
such
# as adding a function pointer to the end of the function table, can be made
# without breaking binary compatibility.  In this case, only the
C_API_VERSION
# (*not* C_ABI_VERSION) would be increased.  Whenever binary compatibility
is
# broken, both C_API_VERSION and C_ABI_VERSION should be increased.
C_API_VERSION = 0x00000006

It's now 7. This is set in numpy/core/setup_common.py. Where are you seeing
7 for 1.6?

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120424/acb14362/attachment.html>


More information about the NumPy-Discussion mailing list