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.
Eric Frederich | 18 Mar 18:35 2014
Picon

struct to dict; dict to struct

Hello,

This is a follow up of the thread "changes from 0.19 to 0.20".
I figured this should have its own thread.

Since moving to 0.20.1 I have been unable to find an example that works.
Does anyone have an example of a cython file that doesn't fail to generate the .c code?
For example, the following code fails the "cython" command.

cdef extern from "example.h":
    
    cdef struct my_date_t:
        int year
        int month
        int day
    
    cdef void print_date(my_date_t d)
    cdef my_date_t give_me_a_date()

def prnt_date(d):
    print_date(d)

def gimmie():
    return give_me_a_date()

--

---
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.
Ido | 18 Mar 15:04 2014
Picon

strange behavior with memoryview / bytearray

Hi, I'm new to Cython (great tool, btw), so perhaps I'm doing something wrong... but here goes:

If I compile and run the following, I get the expected good results:
        x = "abcdef"
        y = bytearray(x)
        z = memoryview(y)
        print x, y, bytearray(z)

===> abcdef abcdef abcdef

But if I set a static type to z, I get that the first character, 'a', becomes the last!
        x = "abcdef"
        y = bytearray(x)
        cdef char [:] z = memoryview(y)
        print x, y, bytearray(z)

===> abcdef abcdef bcdefa

what makes this even stranger, is that if I print the first character of z directly, I get the correct value: "a":
print unichr(z[0])
===> a

FYI, I'm using:
Python 2.7.3
Cython version 0.20.1
On 64-bit Ubuntu

Thanks!
Ido

--

---
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.
tgrav | 17 Mar 18:25 2014

Installing Cython

I am trying to install Cython on my MacBook Pro running OSX 10.9.2 with ActivePython 2.7.5.6.


python setup.py install fails with

gcc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -isysroot / build/temp.macosx-10.5-intel-2.7/Cython/Plex/Scanners.o -o build/lib.macosx-10.5-intel-2.7/Cython/Plex/Scanners.so 
ld: library not found for -lbundle1.o 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 
error: command 'gcc' failed with exit status 1

I tried to google a solution, but without any success.

Cheers
  Tommy

--

---
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 | 18 Mar 01:29 2014
Picon

Cython on Python 3.4

Hi All,

We're starting to get reports of problems with Cython on Python 3.4.
The issue is that we've checked in .C files created with Python 2.7
for our source distributions. So pip install ... fails with this kind
of error on Python 3.4.

statsmodels/tsa/kalmanf/kalman_loglike.c:7131:17: error:
'PyFrameObject' has no member named 'f_tstate'
         (*frame)->f_tstate = tstate;

https://github.com/statsmodels/statsmodels/issues/1311

Is this a known issue? Is it something we're doing wrong? Is there a
way to compile .C files that work Python 2.6 through 3.4?

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.

Yury V. Zaytsev | 17 Mar 11:16 2014

Case study: Python bindings for a simulator using Cython (the making of)

Hi,

After consulting with Stefan, I've decided to post the link to our
recently published case study on re-writing the Python bindings using
Cython for a neuronal network simulation software written in C++:

http://journal.frontiersin.org/Journal/10.3389/fninf.2014.00023/abstract

I don't think that there is anything new in there for the advanced/power
users on this list, but I believe that it might be useful for beginners
who are just considering using Cython and/or are exploring different
options to chose from those that are available out there.

Hope that some will find it interesting,

-- 
Sincerely yours,
Yury V. Zaytsev

--

-- 

--- 
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