[Cython] Fwd: MemoryView.is_f_contig sometimes not defined?

David Hirschfeld dave.hirschfeld at gmail.com
Sat Feb 9 14:03:03 CET 2013


Reposting because I think my original got blocked because of
attachments. Apologies if this appears twice.

I want to allow arbitrary C/F contiguous arrays as input to a cdef
class so I can dispatch to a different calculation method in each
case, avoiding a potentially costly copy.
Unfortunately, it appears that cython is generating incorrect code.
The following minimal example reproduces the problem:

cimport cython

cdef class TestContig:

    cdef cython.bint contig

    def __init__(self, double[:,:] y):
        if y.is_c_contig():
            self.contig = 1
        elif y.is_f_contig():
            self.contig = 1
        else:
            self.contig = 0

    property contig:
        def __get__(self):
            return self.contig

#


C:\temp> python setup.py build_ext --inplace
running build_ext
building 'example' extension
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\cl.exe /c
/nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\dev\bin\Python27\include
-IC:\dev\bin\Python27\PC /Tpexample.cpp
/Fobuild\temp.win32-2.7\Release\example.obj
example.cpp
example.cpp(1277) : error C3861: '__pyx_memviewslice_is_f_contig2':
identifier not found
error: command '"C:\Program Files (x86)\Microsoft Visual Studio
11.0\VC\BIN\cl.exe"' failed with exit status 2
C:\temp>


I'm on Windows7 with 32bit Python2.7 and I tested that compilation
fails with both VS2012 & MinGW32 4.6.1.

NB: If you only check for f-contiguity (or c-contiguity) in the method it
compiles fine, it appears that the bug only appears when you test for
both f and c contiguity in the same method.


Thanks,
Dave


More information about the cython-devel mailing list