summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2015-02-01 13:53:54 (GMT)
committerStefan Krah <skrah@bytereef.org>2015-02-01 13:53:54 (GMT)
commit363af44a4abff02ece61e456d55824f298448992 (patch)
tree1ecc31d3808152ca2f09ded5594cb715dc32a4c2 /Lib
parenta5e1dbef146b9d1aece4e3def828d2b216a07e41 (diff)
downloadcpython-363af44a4abff02ece61e456d55824f298448992.zip
cpython-363af44a4abff02ece61e456d55824f298448992.tar.gz
cpython-363af44a4abff02ece61e456d55824f298448992.tar.bz2
Issue #22445: PyBuffer_IsContiguous() now implements precise contiguity
tests, compatible with NumPy's NPY_RELAXED_STRIDES_CHECKING compilation flag. Previously the function reported false negatives for corner cases.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_buffer.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py
index 1cdc771..0976fa9 100644
--- a/Lib/test/test_buffer.py
+++ b/Lib/test/test_buffer.py
@@ -1007,6 +1007,7 @@ class TestBufferProtocol(unittest.TestCase):
# shape, strides, offset
structure = (
([], [], 0),
+ ([1,3,1], [], 0),
([12], [], 0),
([12], [-1], 11),
([6], [2], 0),
@@ -1078,6 +1079,18 @@ class TestBufferProtocol(unittest.TestCase):
self.assertRaises(BufferError, ndarray, ex, getbuf=PyBUF_ANY_CONTIGUOUS)
nd = ndarray(ex, getbuf=PyBUF_SIMPLE)
+ # Issue #22445: New precise contiguity definition.
+ for shape in [1,12,1], [7,0,7]:
+ for order in 0, ND_FORTRAN:
+ ex = ndarray(items, shape=shape, flags=order|ND_WRITABLE)
+ self.assertTrue(is_contiguous(ex, 'F'))
+ self.assertTrue(is_contiguous(ex, 'C'))
+
+ for flags in requests:
+ nd = ndarray(ex, getbuf=flags)
+ self.assertTrue(is_contiguous(nd, 'F'))
+ self.assertTrue(is_contiguous(nd, 'C'))
+
def test_ndarray_exceptions(self):
nd = ndarray([9], [1])
ndm = ndarray([9], [1], flags=ND_VAREXPORT)