[Cython] "relaxed_strides" test broken with NumPy 1.8

Nathaniel Smith njs at pobox.com
Sun Jan 19 01:04:26 CET 2014


On Sun, Jan 5, 2014 at 8:03 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Nathaniel Smith, 05.01.2014 02:07:
>> On 4 Jan 2014 22:01, "Stefan Behnel" wrote:
>>> Stefan Behnel, 04.01.2014 22:51:
>>>> Stefan Behnel, 04.01.2014 22:47:
>>>>> Nathaniel Smith, 04.01.2014 18:36:
>>>>>>
>>>>>> if not np.ones((10, 1), order="C").flags.f_contiguous:
>>>>>>   # numpy without relaxed stride support
>>>>>>   raise SkipTest
>>>>>
>>>>> https://github.com/cython/cython/commit/e1982505564125714d2010391eecfb8de61626fa
>>>>
>>>> Hmm, but this doesn't seem to work for me in older NumPy versions, although
>>>> the original test used to work there. Should we explicitly test for NumPy
>>>> 1.8+ as well?
>>>
>>> https://github.com/cython/cython/commit/a95d8f912c995300a13fc244ee71bc277668cb9a
>>
>> No, I'm missing something now; AFAIK there are only two numpy behaviors:
>> with relaxed strides and without relaxed strides, and version number should
>> be irrelevant beyond that. What's different between
>> 1.8-without-relaxed-strides and 1.7 that makes the test break?
>
> Mark would certainly know better than me.
>
> In any case, the test works with both NumPy 1.7 (tested with Py 2.x and
> 3.[12] on Jenkins) and NumPy 1.8 with relaxed strides support, but not with
> NumPy 1.8 without relaxed strides. The last two were tested in Py3.3 only,
> in case that matters. I also tested it locally now (in 3.3) and your
> snippet successfully distinguishes the two builds for me, but the test
> starts to fail when I disable relaxed strides in NumPy and works when it's
> enabled.

Then either there's a bug in numpy or in cython -- 1.7 and
1.8-without-relaxed-strides are supposed to be compatible, so if your
test works on one and not on the other, that's a bug in the libraries
somewhere, not in the test suite. Adding version checks will just hide
this bug, not fix anything.

(Personally I'd double-check whether the cython memoryview code is
doing its own version check, and wrongly assuming that if numpy
version >= 1.8, then relaxed strides = True...)

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org


More information about the cython-devel mailing list