Stefan Behnel | 2 Apr 09:42 2014
Picon

Re: CYTHON_INLINE causing errors on MacOS with clang

Daniel Farrell, 02.04.2014 04:43:
> A follow up to this. In the end I removed the inline from the functions in,
> https://github.com/bmcage/odes/blob/master/scikits/odes/sundials/common_defs.pxd
>  
> 
> This allowed the compilation to complete without further errors, however 
> the end product is not valid. When running the tests that come with the 
> scikits.odes package produce an namespace error when loading the complied 
> code,
> 
> Expected in: flat namespace

What is expected there? The function symbol? Or something else? When
reporting errors, please always take care to provide the complete error
message, including any context that might help in understanding it (and/or
the actual problem).

The error message above generally hints at some kind of linking problem,
maybe a missing library.

Stefan

--

-- 

--- 
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

(Continue reading)

Skipper Seabold | 1 Apr 22:57 2014
Picon

Supporting Capsule and CObject?

Hi,

I am trying to use the header file provided by numpy [1] so that our
code builds on both Python 2 and Python 3. I must be missing something
though. So far I can only get it to compile on Python 2. Python 3
results in the attached error log. Two questions.

1) why do I need to use object in the declaration rather than a
pointer to cython.object.PyObject to get it to compile on Python 2.
2) Any idea why this isn't compiling on Python 3?

[1] https://github.com/numpy/numpy/blob/master/numpy/core/include/numpy/npy_3kcompat.h

Skipper

------

#mwe.pyx
cimport cython

import scipy.linalg
from numpy import float64
from numpy cimport float64_t, PyArray_EMPTY, ndarray
cimport numpy as cnp
cnp.import_array()

ctypedef float64_t DOUBLE

from blas cimport dgemm_t

(Continue reading)

Jamie Diprose | 31 Mar 00:24 2014
Picon

Python classes as parameter types

Hi

I know this is possible using cdef classes, but I was wondering if its possible to use Python classes as parameter types. For example:

class Cat:
    def __init__(self, str name):
        self.name = name

class Dog:
    def __init__(self, str name):
        self.name = name

    def eat(self, Cat cat):
        print "I am eating " + cat.name + " the Cat"


I get the following error:

Error compiling Cython file:
------------------------------------------------------------
...

class Dog:
    def __init__(self, str name):
        self.name = name

    def eat(self, Cat cat):
                 ^
------------------------------------------------------------

objects.pyx:12:18: 'Cat' is not a type identifier

Thanks for your help

Jamie

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Bruce Cropley | 29 Mar 00:55 2014
Picon

AttributeError: 'CClassDefNode' object has no attribute 'scope'

While attempting to build kivy, (with Python 2.7.5 on OS X 10.9.2) I get the following cython crash:

File "Visitor.py", line 170, in Cython.Compiler.Visitor.TreeVisitor._visit (/private/var/folders/xd/52m0srtj17d2f54vrv_wy2940000gn/T/pip_build_root/cython/Cython/Compiler/Visitor.c:4284)
File "/Library/Python/2.7/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 1469, in visit_CClassDefNode
node = self.visit_ClassDefNode(node)
File "Visitor.py", line 356, in Cython.Compiler.Visitor.EnvTransform.visit_ClassDefNode (/private/var/folders/xd/52m0srtj17d2f54vrv_wy2940000gn/T/pip_build_root/cython/Cython/Compiler/Visitor.c:8003)
AttributeError: 'CClassDefNode' object has no attribute 'scope'

More details at:
http://pastebin.com/FQpf4ZzT

Any suggestions?

Thanks,
Bruce

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jay L. | 27 Mar 17:39 2014
Picon

Cython Cdef Func. via Python multiprocessing pool

Is it possible to utilize the standard library apply_async method (or map) to make
calls to a cpdef function?

For example using dummy functions that only illustrate the general idea;
the sub matrix slicing is fictional within the cython_func.:

caller.py

import multiprocessing as mp

pool = mp.Pool(2)
n = 10
a = np.arange(n*n).reshape(n,n)
for offset in range(2):
    res = pool.apply_async(cython_func, args=(a, n, offset))
res.get()

callee.pyx
cpdef cython_func(double [:,:] a, int n):
    cdef int i, j
    for i in range(offset, n):
        for j in range(offset, n):
            a[i,j] += 1

I am seeing issues with res.get() and I suspect that the Python check to
see if the python_func has finished is the issue.

Error is: TypeError: 'int' does not have the buffer interface

Since I am working on a memory buffer, I tried including an explicit return
in cython_func, but that resulted in the same issue.

P.S. I realize that using OpenMP and prange is available - I am curious
about compatibility with the multiprocessing module.

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
chetan raga | 27 Mar 06:34 2014
Picon

iam new to cython can any body help me in this

root <at> emb-ubu-085:~/Desktop/reports# python setup.py build
running build
running build_ext
skipping 'rectangle.cpp' Cython extension (up-to-date)
building 'rectangle' extension
i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c rectangle.cpp -o build/temp.linux-i686-2.7/rectangle.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c Rectangle.cpp -o build/temp.linux-i686-2.7/Rectangle.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
Rectangle.cpp: In member function ‘int Rectangle::getLength()’:
Rectangle.cpp:21:1: error: ‘QString’ was not declared in this scope
Rectangle.cpp:21:9: error: expected ‘;’ before ‘m_guids’
Rectangle.cpp:22:23: error: ‘m_guids’ was not declared in this scope
Rectangle.cpp:23:26: error: ‘guids’ was not declared in this scope
Rectangle.cpp:34:3: error: ‘result1’ was not declared in this scope
Rectangle.cpp:37:28: error: ‘result1’ was not declared in this scope
Rectangle.cpp:25:6: warning: unused variable ‘index’ [-Wunused-variable]
Rectangle.cpp:26:6: warning: unused variable ‘res’ [-Wunused-variable]
error: command 'i686-linux-gnu-gcc' failed with exit status 1

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Skipper Seabold | 25 Mar 23:34 2014
Picon

preserving order of memoryviews?

I'm really not sure what I'm doing wrong here. Can someone set me straight?

I have a Fortran-order array. I pass it to a Cython function and it
gets transposed (?). MWE below

mwe.pyx
-------------

cimport cython

from numpy import asarray
from numpy cimport complex128_t

ctypedef complex128_t dcomplex

 <at> cython.boundscheck(False)
 <at> cython.wraparound(False)
 <at> cython.cdivision(True)
def func1(dcomplex[::1,:] T_mat):
    print "T_mat: ", asarray(<dcomplex[:2, :2] *> &T_mat[0,0], order='F')
    print asarray(<dcomplex[:2, :2] *> &T_mat[0,0], order='F').flags
    print asarray(<dcomplex[:2, :2] *> &T_mat[0,0], order='F').strides
    print
    return

------------------------------

I compile with

cython mwe.pyx
gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing
-I/usr/include/python2.7
-I/usr/local/lib/python2.7/dist-packages/numpy/core/include -o mwe.so
mwe.c

Then I run the following code

----
T_mat = np.array([[ 0.6643632+0.j,  1.0000000+0.j],
                  [ 0.0000000+0.j,  0.0000000+0.j]], order='F')
print T_mat
print T_mat.flags
print T_mat.strides
print

from mwe import func1
func1(T_mat)
----

and receive this output.

----
[[ 0.6643632+0.j  1.0000000+0.j]
 [ 0.0000000+0.j  0.0000000+0.j]]
  C_CONTIGUOUS : False
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False
(16, 32)

T_mat:  [[ 0.6643632+0.j  0.0000000+0.j]
 [ 1.0000000+0.j  0.0000000+0.j]]
  C_CONTIGUOUS : False
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False
(16, 32)
----

What am I missing?

Thanks,

Skipper

--

-- 

--- 
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mads Dørup | 23 Mar 12:01 2014
Picon

Call python code from c via cython

Hi guys

If anyone could help me with this (probably super beginner question) it would be much appreciated:

http://stackoverflow.com/questions/22589868/call-python-code-from-c-via-cython

Thanks in advance

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Joshua Adelman | 20 Mar 18:15 2014
Picon

undefined reference to `__Pyx_PyInt_As_unsigned_int error

I recently updated from Cython 0.19.2 to 0.20.1 on Windows using the Anaconda python distribution and ran
into a strange bug. Code that compiled using the latter version of cython, suddenly started throwing a gcc
error complaining about an undefined reference to `__Pyx_PyInt_As_unsigned_int. The layout of the
code is that I have a large number of files, f1.pyx through fN.pyx and they all import/cimport from
base.pyx/base.pxd. None of the fN.pyx files depend on each other. I'm using cythonize in my setup.py to
figure out the dependencies and changes. As the setup.py sequentially compiles all of the modules, it
will get to one and give the undefined reference error. Strangely, if I then delete the offending fN.c file
and re-start the compilation, the problematic module will compile and then I'll get the same error on a
subsequent module.

Examining the generated .c files before and after, I see the following difference where f100.c.bak was the
version that failed to compile (the source f100.pyx has not been changed at all between builds):

$ diff f100.c f100.c.bak
1c1
< /* Generated by Cython 0.20.1 on Thu Mar 20 23:36:56 2014 */
---
> /* Generated by Cython 0.20.1 on Thu Mar 20 23:13:44 2014 */
16226,16227c16226
<     PyErr_Format(PyExc_TypeError, "Cannot convert Python object xnr to unsigned int");
<     {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
---
>     __pyx_v_8res_5fcode_6base_xnr = __Pyx_PyInt_As_unsigned_int(o); if
((__pyx_v_8res_5fcode_6base_xnr == (unsigned int)-1)
&& PyErr_Occurred()) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L2_error;};

xnr is a module variable defined in base.pxd as:
unsigned int xnr

and fX.pyx imports it via:
from base import *
from base cimport *

If I clean out the all of the generated .c and .pyd files and recompile from scratch, then I get the same error
springing up (seemingly stochastically) in a different fX.pyx, with the same pattern of diff shown
above. I can remove its .c forcing a re-cythonization of the .pyx file and then it works and fails on some
other module. 

I can use conda to switch back to the previous version of cython (0.19.2 - py27_0) with all other packages
being the same, and I can then compile everything correctly. 

Does anyone have any idea as to what may be going on? This type of non-deterministic codgen seems really
bizarre to me.

Any help would be most appreciated.

Josh

--

-- 

--- 
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vighnesh Birodkar | 20 Mar 11:38 2014
Picon

Array of Vectors

What is the correct way of declaring an array or vectors ? The following syntax produces an error

from libcpp.vector cimport vector
ctypedef vector[int] array[10]


--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Tom Beddard | 19 Mar 13:23 2014

Clang issue installing cython on OSX 10.9.2

When trying sudo pip install cython with python 2.7.5 and pip 1.4.1 I get the following error:

cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c imposm/cache/tc.c -o build/temp.macosx-10.9-intel-2.7/imposm/cache/tc.o

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1


I think in the recent OSX update clang got bumped up to v5.1:
cc -v
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

I've tried setting the environment variable ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future without luck though

Any suggestions on how to install it now?
Thanks!

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gmane