8000 Header cleanup by charris · Pull Request #102 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Header cleanup #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ENH: core: Create a header in which to move deprecated API
  • Loading branch information
Mark Wiebe authored and charris committed Jul 6, 2011
commit 21ce29c8b207640e5e5ac5e8bd581a54a02650ef
45 changes: 31 additions & 14 deletions numpy/core/include/numpy/ndarraytypes.h
8000
Original file line number Diff line number Diff line change
Expand Up @@ -674,17 +674,14 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *);
* Means c-style contiguous (last index varies the fastest). The data
* elements right after each other.
*/
#define NPY_CONTIGUOUS 0x0001
#define NPY_ARRAY_C_CONTIGUOUS 0x0001

/*
* set if array is a contiguous Fortran array: the first index varies
* the fastest in memory (strides array is reverse of C-contiguous
* array)
*/
#define NPY_FORTRAN 0x0002

#define NPY_C_CONTIGUOUS NPY_CONTIGUOUS
#define NPY_F_CONTIGUOUS NPY_FORTRAN
#define NPY_ARRAY_F_CONTIGUOUS 0x0002

/*
* Note: all 0-d arrays are CONTIGUOUS and FORTRAN contiguous. If a
Expand All @@ -695,51 +692,67 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *);
* If set, the array owns the data: it will be free'd when the array
* is deleted.
*/
#define NPY_OWNDATA 0x0004
#define NPY_ARRAY_OWNDATA 0x0004

/*
* An array never has the next four set; they're only used as parameter
* flags to the the various FromAny functions
*/

/* Cause a cast to occur regardless of whether or not it is safe. */
#define NPY_FORCECAST 0x0010
#define NPY_ARRAY_FORCECAST 0x0010

/*
* Always copy the array. Returned arrays are always CONTIGUOUS,
* ALIGNED, and WRITEABLE.
*/
#define NPY_ENSURECOPY 0x0020
#define NPY_ARRAY_ENSURECOPY 0x0020

/* Make sure the returned array is a base-class ndarray */
#define NPY_ENSUREARRAY 0x0040
#define NPY_ARRAY_ENSUREARRAY 0x0040

/*
* Make sure that the strides are in units of the element size Needed
* for some operations with record-arrays.
*/
#define NPY_ELEMENTSTRIDES 0x0080
#define NPY_ARRAY_ELEMENTSTRIDES 0x0080

/*
* Array data is aligned on the appropiate memory address for the type
* stored according to how the compiler would align things (e.g., an
* array of integers (4 bytes each) starts on a memory address that's
* a multiple of 4)
*/
#define NPY_ALIGNED 0x0100
#define NPY_ARRAY_ALIGNED 0x0100

/* Array data has the native endianness */
#define NPY_NOTSWAPPED 0x0200
#define NPY_ARRAY_NOTSWAPPED 0x0200

/* Array data is writeable */
#define NPY_WRITEABLE 0x0400
#define NPY_ARRAY_WRITEABLE 0x0400

/*
* If this flag is set, then base contains a pointer to an array of
* the same size that should be updated with the current contents of
* this array when this array is deallocated
*/
#define NPY_UPDATEIFCOPY 0x1000
#define NPY_ARRAY_UPDATEIFCOPY 0x1000

/*
* These versions of the above flags are not yet deprecated,
* but the intention is to do so in a future release.
*/
#define NPY_C_CONTIGUOUS NPY_ARRAY_C_CONTIGUOUS
#define NPY_F_CONTIGUOUS NPY_ARRAY_F_CONTIGUOUS
#define NPY_OWNDATA NPY_ARRAY_OWNDATA
#define NPY_FORCECAST NPY_ARRAY_FORCECAST
#define NPY_ENSURECOPY NPY_ARRAY_ENSURECOPY
#define NPY_ENSUREARRAY NPY_ARRAY_ENSUREARRAY
#define NPY_ELEMENTSTRIDES NPY_ARRAY_ELEMENTSTRIDES
#define NPY_ALIGNED NPY_ARRAY_ALIGNED
#define NPY_NOTSWAPPED NPY_ARRAY_NOTSWAPPED
#define NPY_WRITEABLE NPY_ARRAY_WRITEABLE
#define NPY_UPDATEIFCOPY NPY_ARRAY_UPDATEIFCOPY

/* This flag is for the array interface */
#define NPY_ARR_HAS_DESCR 0x0800
Expand Down Expand Up @@ -1452,4 +1465,8 @@ typedef struct {
*/
} PyArrayInterface;

#ifndef NPY_NO_DEPRECATED_API
#include "npy_deprecated_api.h"
#endif

#endif /* NPY_ARRAYTYPES_H */
19 changes: 19 additions & 0 deletions numpy/core/include/numpy/npy_deprecated_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef _NPY_DEPRECATED_API_H
#define _NPY_DEPRECATED_API_H

/*
* This header exists to collect all dangerous/deprecated NumPy API.
*
* This is an attempt to remove bad API, the proliferation of macros,
* and namespace pollution currently produced by the NumPy headers.
*/

#ifdef NPY_NO_DEPRECATED_API
#error Should never include npy_deprecated_api directly.
#endif

/* These array flags are deprecated as of NumPy 1.7 */
#define NPY_CONTIGUOUS NPY_ARRAY_C_CONTIGUOUS
#define NPY_FORTRAN NPY_ARRAY_F_CONTIGUOUS

#endif
0