From 79d22dcef7947347660cbb953cb54ee3b38822f5 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Thu, 21 Mar 2013 14:23:21 +0100 Subject: BLD: Add NPY_RELAXED_STRIDES_CHECKING flag This flag will toggle to a new definition for the contiguous flags where only the memory layout is forced to be correct. As a particular example this means that np.ones((3,1)) can be both C and F-Contiguous and its stride[-1] can be arbitrary but the array still contiguous. The flag will also make most new arrays be created with MAX_INTP as stride so that unsafe usage of the stride will surface more commonly. --- numpy/core/setup.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'numpy/core/setup.py') diff --git a/numpy/core/setup.py b/numpy/core/setup.py index 37f649e6b..c65012126 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -15,6 +15,9 @@ from setup_common import * # Set to True to enable multiple file compilations (experimental) ENABLE_SEPARATE_COMPILATION = (os.environ.get('NPY_SEPARATE_COMPILATION', "1") != "0") +# Set to True to enable relaxed strides checking. This (mostly) means +# that `strides[dim]` is ignored if `shape[dim] == 1` when setting flags. +NPY_RELAXED_STRIDES_CHECKING = (os.environ.get('NPY_RELAXED_STRIDES_CHECKING', "0") != "0") # XXX: ugly, we use a class to avoid calling twice some expensive functions in # config.h/numpyconfig.h. I don't see a better way because distutils force @@ -435,6 +438,9 @@ def configuration(parent_package='',top_path=None): if ENABLE_SEPARATE_COMPILATION: moredefs.append(('ENABLE_SEPARATE_COMPILATION', 1)) + if NPY_RELAXED_STRIDES_CHECKING: + moredefs.append(('NPY_RELAXED_STRIDES_CHECKING', 1)) + # Get long double representation if sys.platform != 'darwin': rep = check_long_double_representation(config_cmd) @@ -532,6 +538,9 @@ def configuration(parent_package='',top_path=None): if ENABLE_SEPARATE_COMPILATION: moredefs.append(('NPY_ENABLE_SEPARATE_COMPILATION', 1)) + if NPY_RELAXED_STRIDES_CHECKING: + moredefs.append(('NPY_RELAXED_STRIDES_CHECKING', 1)) + # Check wether we can use inttypes (C99) formats if config_cmd.check_decl('PRIdPTR', headers = ['inttypes.h']): moredefs.append(('NPY_USE_C99_FORMATS', 1)) -- cgit v1.2.1