[Cython] vcvarsall.bat error on win32 with mingw when using cython_inline

2012-05-31 Thread Dave Hirschfeld
Hi cython devs, I got the "unable to find vcvarsall.bat" error when using cython_inline when trying to compile with mingw. Using cython normally (creating a setup.py file) worked fine however. I was able to fix the problem for me by changing inline.py to parse the config files before building t

[Cython] Fused types don't work with cdef classes?

2013-02-08 Thread Dave Hirschfeld
Is this a bug? The following code fails to compile on windows VS2012, 32bit Python2.7 with a recent 0.19-pre github cython: cimport cython ctypedef fused char_or_float: cython.char cython.float cdef class FusedExample: def __init__(self, char_or_float x): pass # Resu

Re: [Cython] Fused types don't work with cdef classes?

2013-02-13 Thread Dave Hirschfeld
Robert Bradshaw writes: > > Yes, this is a bug; there is a bad interaction between fused types and > special methods. > > I created http://trac.cython.org/cython_trac/ticket/802 > Thanks for following up. My actual use-case was to allow either 1D or 2D MemoryView inputs to a function by simpl

[Cython] No matching signature with fused memoryview and None default

2013-02-25 Thread Dave Hirschfeld
With the following code I get a "No matching signature found" error. Is this a bug? ``` %%cython cimport cython ctypedef fused floating: cython.double cython.float def nosignature(floating[:] x, floating[:] myarray = None): print myarray is None return x ``` In [39]: nosignatur

[Cython] Can't assign memview cast to memview slice

2013-02-26 Thread Dave Hirschfeld
The following works: ``` %%cython cimport cython import numpy as np cimport numpy as np def f(double[:,:] arr): cdef double[:] res = np.zeros(2*arr.size, dtype=np.float64) cdef double[:] tmp tmp = &arr[0,0] res[:arr.size] = tmp return res ``` whereas the following: ``` %%cyt

[Cython] Non-deterministic behavoiur?

2013-02-27 Thread Dave Hirschfeld
Using the following test code: import numpy as np from lapack import dgelsy from numpy.linalg import lstsq A = np.array([[ 0.12, -8.19, 7.69, -2.26, -4.71], [-6.91, 2.22, -5.12, -9.08, 9.96], [-3.33, -8.94, -6.72, -4.4 , -9.98], [ 3.97, 3.33, -2.74, -7.92, -3.2 ]]) # b =

[Cython] MemoryViews require writeable arrays?

2013-02-27 Thread Dave Hirschfeld
%%cython cimport cython import numpy as np cimport numpy as np @cython.boundscheck(False) @cython.wraparound(False) @cython.cdivision(True) cpdef double[:] return_one(double[:] x): return np.array([1.0]) In [43]: x = randn(3) ...: return_one(x) Out[43]: In [44]: x.flags['WRITEABLE'] =

Re: [Cython] MemoryViews require writeable arrays?

2013-02-27 Thread Dave Hirschfeld
Dave Hirschfeld writes: > > cpdef double[:] return_one(double[:] x): > return np.array([1.0]) > > In [43]: x = randn(3) > ...: return_one(x) > Out[43]: > > In [44]: x.flags['WRITEABLE'] = False > ...: return_one(x) > ValueError: buffer

Re: [Cython] Non-deterministic behavoiur?

2013-02-28 Thread Dave Hirschfeld
Dave Hirschfeld writes: > > Using the following test code: > > So, it seems either typing the array as a memview or printing res > will screw up the calculation. > > The cython code is given below. Any ideas if this is a cython bug or > something > I'm

Re: [Cython] Non-deterministic behavoiur?

2013-02-28 Thread Dave Hirschfeld
Dave Hirschfeld writes: > > Dave Hirschfeld writes: > > > > > Using the following test code: > > > > > So, it seems either typing the array as a memview or printing res > > will screw up the calculation. > > > > The cython cod

[Cython] MemoryView Casting slow compared to ndarray buffer syntax

2013-02-28 Thread Dave Hirschfeld
%%cython cimport cython import numpy as np cimport numpy as np ctypedef np.float64_t float64_t @cython.boundscheck(False) @cython.wraparound(False) @cython.cdivision(True) def echo_numpy(np.ndarray[float64_t, ndim=1] x): return x @cython.boundscheck(False) @cython.wraparound(False) @cython.

Re: [Cython] MemoryViews require writeable arrays?

2013-02-28 Thread Dave Hirschfeld
Sturla Molden writes: > > On 27.02.2013 20:05, Dave Hirschfeld wrote: > > > Is this a required restriction? Is there any workaround? > > http://www.python.org/dev/peps/pep-3118/ > > What you should consider is the "readonly" field in "struct bufferin

Re: [Cython] Upcoming cython/numpy breakage with stride checking

2013-04-08 Thread Dave Hirschfeld
Dag Sverre Seljebotn writes: > > cdef np.ndarray[double, mode='fortran'] arr > > that relies on PEP 3118 contiguous-flags and I did no checking myself. > Lots of Cython code does this instead of memoryviews (I still write my > own code that way). > > The memory views OTOH does their own chec

[Cython] libc.string msvc incompatibility

2013-04-23 Thread Dave Hirschfeld
When trying to use strcasecmp from libc.string I get an error compiling with msvc: error C3861: 'strcasecmp': identifier not found It seems MS have decided to call it by another name - _stricmp ...amongst others: http://botsikas.blogspot.co.uk/2011/12/strcasecmp-identifier-not-found- when.htm

Re: [Cython] -O3 causes MinGW to segfault python

2013-04-29 Thread Dave Hirschfeld
Stefan Behnel writes: > > David Hirschfeld, 29.04.2013 11:58: > > Forwarded because attachments were too large. The source files and > > generated .c file can now be viewed at: > > https://gist.github.com/dhirschfeld/5480711 > > > > Is this a bug or is the recommendation to not build with -O3?

Re: [Cython] [Re] OpenMP thread private variable not recognized (bug report + discussion)

2014-08-12 Thread Dave Hirschfeld
Sturla Molden writes: > > "Leon Bottou" wrote: > > > I am making heavy uses of OpenBlas which also uses OpenMP. > > Using the same queue manager prevents lots of CPU provisioning problem. > > Using multiple queue managers in the same code does not work as well because > > they are not aware o

[Cython] Can't assign numpy array to memoryview

2014-12-08 Thread Dave Hirschfeld
It appears that you can't assign an ndarray to a memoryview slice? Is this correct/expected behaviour? Whilst there are a couple of possible workarounds it would be nice if this just worked as it's a slightly surprising deviation from the ndarray behaviour. Broken example: ``` In [3]: %%cython

Re: [Cython] Can't assign numpy array to memoryview

2014-12-08 Thread Dave Hirschfeld
Dave Hirschfeld writes: > > It appears that you can't assign an ndarray to a memoryview slice? Is > this correct/expected behaviour? > > Whilst there are a couple of possible workarounds it would be nice if > this just worked as it's a slightly surprising d