Navigation Menu

Skip to content

Commit

Permalink
ENH: core: Make NumPy trunk ABI-compatible with 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mwiebe committed Jan 28, 2011
1 parent 0a01142 commit 3e58b8d
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 279 deletions.
13 changes: 12 additions & 1 deletion numpy/add_newdocs.py
Expand Up @@ -1514,11 +1514,22 @@
If provided, the calculation is done into this array.
dtype : None or data type
If provided, forces the calculation to use the data type specified.
Note that you may have to also give a more liberal ``casting``
parameter to allow the conversions.
order : 'C', 'F', 'A', or 'K'
Controls the memory layout of the output.
Controls the memory layout of the output. 'C' means it should
be Fortran contiguous. 'F' means it should be Fortran contiguous,
'A' means it should be 'F' if the inputs are all 'F', 'C' otherwise.
'K' means it should be as close to the layout as the inputs as
is possible, including arbitrarily permuted axes.
casting : 'no', 'equiv', 'safe', 'same_kind', 'unsafe'
Controls what kind of data casting may occur. Setting this to
'unsafe' is not recommended, as it can adversely affect accumulations.
'no' means the data types should not be cast at all. 'equiv' means
only byte-order changes are allowed. 'safe' means only casts
which can preserve values are allowed. 'same_kind' means only
safe casts or casts within a kind, like float64 to float32, are
allowed. 'unsafe' means any data conversions may be done.
Returns
-------
Expand Down
546 changes: 275 additions & 271 deletions numpy/core/code_generators/numpy_api.py

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions numpy/core/include/numpy/ndarraytypes.h
Expand Up @@ -572,8 +572,7 @@ typedef struct _PyArray_Descr {
* '>' (big), '<' (little), '|'
* (not-applicable), or '=' (native).
*/
char unused;
int flags; /* flag describing data type */
char flags; /* flags describing data type */
int type_num; /* number representing this type */
int elsize; /* element size for this type */
int alignment; /* alignment needed for this type */
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/setup_common.py
Expand Up @@ -21,7 +21,7 @@
# 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 = 0x02000000
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
Expand Down
2 changes: 0 additions & 2 deletions numpy/core/src/multiarray/arraytypes.c.src
Expand Up @@ -3661,7 +3661,6 @@ static PyArray_Descr @from@_Descr = {
PyArray_@from@LTR,
'@endian@',
0,
0,
PyArray_@from@,
0,
_ALIGN(@align@),
Expand Down Expand Up @@ -3752,7 +3751,6 @@ NPY_NO_EXPORT PyArray_Descr @from@_Descr = {
PyArray_@kind@LTR,
PyArray_@from@LTR,
'@endian@',
0,
@isobject@,
PyArray_@from@,
@num@*sizeof(@fromtyp@),
Expand Down
6 changes: 6 additions & 0 deletions numpy/core/src/multiarray/lowlevel_strided_loops.c.src
Expand Up @@ -681,6 +681,7 @@ NPY_NO_EXPORT PyArray_StridedTransferFn *
* byte, short, int, long, longlong,
* half, float, double, longdouble,
* float, double, longdouble#
* #is_bool1 = 1, 0*17#
* #is_half1 = 0*11, 1, 0*6#
* #is_float1 = 0*12, 1, 0, 0, 1, 0, 0#
* #is_double1 = 0*13, 1, 0, 0, 1, 0#
Expand All @@ -704,6 +705,7 @@ NPY_NO_EXPORT PyArray_StridedTransferFn *
* byte, short, int, long, longlong,
* half, float, double, longdouble,
* float, double, longdouble#
* #is_bool2 = 1, 0*17#
* #is_half2 = 0*11, 1, 0*6#
* #is_float2 = 0*12, 1, 0, 0, 1, 0, 0#
* #is_double2 = 0*13, 1, 0, 0, 1, 0#
Expand Down Expand Up @@ -771,7 +773,11 @@ NPY_NO_EXPORT PyArray_StridedTransferFn *

#else

# if @is_bool2@
# define _CONVERT_FN(x) ((npy_bool)(x != 0))
# else
# define _CONVERT_FN(x) ((_TYPE2)x)
# endif

#endif

Expand Down
12 changes: 10 additions & 2 deletions numpy/core/src/multiarray/multiarraymodule.c
Expand Up @@ -45,6 +45,9 @@ NPY_NO_EXPORT int NPY_NUMUSERTYPES = 0;
#include "convert_datatype.h"
#include "new_iterator_pywrap.h"

/* Only here for API compatibility */
NPY_NO_EXPORT PyTypeObject PyBigArray_Type;

/*NUMPY_API
* Get Priority from object
*/
Expand Down Expand Up @@ -734,9 +737,14 @@ PyArray_MatrixProduct(PyObject *op1, PyObject *op2)
PyArray_Descr *typec;
NPY_BEGIN_THREADS_DEF;

PyArrayObject *ops_array[2];

ops_array[0] = op1;
ops_array[1] = op2;
typenum = PyArray_ObjectType(op1, 0);
typenum = PyArray_ObjectType(op2, typenum);
typec = PyArray_DescrFromType(typenum);

Py_INCREF(typec);
ap1 = (PyArrayObject *)PyArray_FromAny(op1, typec, 0, 0, ALIGNED, NULL);
if (ap1 == NULL) {
Expand Down Expand Up @@ -2073,7 +2081,7 @@ array_arange(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kws) {
NPY_NO_EXPORT unsigned int
PyArray_GetNDArrayCVersion(void)
{
return (unsigned int)NPY_VERSION;
return (unsigned int)NPY_ABI_VERSION;
}

/*NUMPY_API
Expand All @@ -2082,7 +2090,7 @@ PyArray_GetNDArrayCVersion(void)
NPY_NO_EXPORT unsigned int
PyArray_GetNDArrayCFeatureVersion(void)
{
return (unsigned int)NPY_FEATURE_VERSION;
return (unsigned int)NPY_API_VERSION;
}

static PyObject *
Expand Down

0 comments on commit 3e58b8d

Please sign in to comment.