diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2017-04-26 17:44:10 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-26 17:44:10 -0600 |
| commit | bca792293c05b01b8d356caa707f82c02759eee6 (patch) | |
| tree | aeef04b5b6d44b30094b0281a210d8a43644dd8b /numpy | |
| parent | f63e37d8769931f34e080a40f38470b06e72931b (diff) | |
| parent | 39a21ddf4deb32a6a7db5a0b890f064166c04a77 (diff) | |
| download | numpy-bca792293c05b01b8d356caa707f82c02759eee6.tar.gz | |
Merge pull request #8999 from charris/relaxed-strides-debug-option
TST: Enable NPY_RELAXED_STRIDES_DEBUG environment variable.
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/setup.py | 14 | ||||
| -rw-r--r-- | numpy/core/src/multiarray/ctors.c | 8 |
2 files changed, 20 insertions, 2 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py index a22d1ef9d..20d4c7792 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -20,6 +20,12 @@ from setup_common import * # that `strides[dim]` is ignored if `shape[dim] == 1` when setting flags. NPY_RELAXED_STRIDES_CHECKING = (os.environ.get('NPY_RELAXED_STRIDES_CHECKING', "1") != "0") +# Put NPY_RELAXED_STRIDES_DEBUG=1 in the environment if you want numpy to use a +# bogus value for affected strides in order to help smoke out bad stride usage +# when relaxed stride checking is enabled. +NPY_RELAXED_STRIDES_DEBUG = (os.environ.get('NPY_RELAXED_STRIDES_DEBUG', "0") != "0") +NPY_RELAXED_STRIDES_DEBUG = NPY_RELAXED_STRIDES_DEBUG and NPY_RELAXED_STRIDES_CHECKING + # 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 # config.h generation inside an Extension class, and as such sharing @@ -436,9 +442,14 @@ def configuration(parent_package='',top_path=None): # Inline check inline = config_cmd.check_inline() + # Use relaxed stride checking if NPY_RELAXED_STRIDES_CHECKING: moredefs.append(('NPY_RELAXED_STRIDES_CHECKING', 1)) + # Use bogus stride debug aid when relaxed strides are enabled + if NPY_RELAXED_STRIDES_DEBUG: + moredefs.append(('NPY_RELAXED_STRIDES_DEBUG', 1)) + # Get long double representation if sys.platform != 'darwin': rep = check_long_double_representation(config_cmd) @@ -542,6 +553,9 @@ def configuration(parent_package='',top_path=None): if NPY_RELAXED_STRIDES_CHECKING: moredefs.append(('NPY_RELAXED_STRIDES_CHECKING', 1)) + if NPY_RELAXED_STRIDES_DEBUG: + moredefs.append(('NPY_RELAXED_STRIDES_DEBUG', 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)) diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index b6e4b607b..0506d3dee 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -3831,10 +3831,12 @@ _array_fill_strides(npy_intp *strides, npy_intp *dims, int nd, size_t itemsize, else { not_cf_contig = 0; } +#if NPY_RELAXED_STRIDES_DEBUG + /* For testing purpose only */ if (dims[i] == 1) { - /* For testing purpose only */ strides[i] = NPY_MAX_INTP; } +#endif /* NPY_RELAXED_STRIDES_DEBUG */ #endif /* NPY_RELAXED_STRIDES_CHECKING */ } #if NPY_RELAXED_STRIDES_CHECKING @@ -3859,10 +3861,12 @@ _array_fill_strides(npy_intp *strides, npy_intp *dims, int nd, size_t itemsize, else { not_cf_contig = 0; } +#if NPY_RELAXED_STRIDES_DEBUG + /* For testing purpose only */ if (dims[i] == 1) { - /* For testing purpose only */ strides[i] = NPY_MAX_INTP; } +#endif /* NPY_RELAXED_STRIDES_DEBUG */ #endif /* NPY_RELAXED_STRIDES_CHECKING */ } #if NPY_RELAXED_STRIDES_CHECKING |
