Skip to main content

All Questions

Tagged with
1 vote
1 answer
81 views

Cython fused dtype memoryview won't complie

I have some code where I (am trying to) do roughly the following: ctypedef fused Raster_t: numpy.uint8_t numpy.uint16_t cdef class MyClass: # shape is (rows, cols, channels) cdef ...
Steve O'Neill's user avatar
0 votes
1 answer
39 views

Cython: How to pass a numpy memoryview to a nogil cdef function

I would like to send a numpy array (memoryview) to another Cython function. cdef int function(int[:,:] ref) nogil: pass cpdef test(): cdef np.ndarray[int, ndim=2] ref = np.full((10,10),0) ...
spamEggsAndSpam's user avatar
0 votes
1 answer
70 views

Creating a cython memoryview manually

I have a contiguous 1-d numpy array that holds data. However, this array is really a buffer, and I have several numpy views to access that data. These views have different shapes, ndims, offsets etc .....
G. Fougeron's user avatar
1 vote
0 answers
109 views

Cython: Memoryviewslice vs C array

I define a C function with memoryview input to work with a NumPy array, but a pure C-defined temporary float array can not work with 'base_func'. Error: Operation not allowed without gil How can I ...
LeonM's user avatar
  • 45
2 votes
1 answer
206 views

Cython returned memoryview is always considered uninitialized

Similar to Cython Memoryview as return value, but I didn't see a solution other than hacking the generated C code. I'm using Cython 3.0, but it looks like the result is the same with <3. Here's an ...
djhoese's user avatar
  • 3,647
0 votes
0 answers
78 views

How to transpose a Cython memoryview slice?

I am trying to calculate the transpose of a Cython typed memoryview slice (eg. a 2D part of a 3D array). I am encountering a transpose error specifically when I try to transpose a 2D slice of a 3D ...
Eric's user avatar
  • 35
1 vote
2 answers
120 views

Why does the memoryview assignment from array have python interactions?

When compiled with cython -a my-file.pyx, this simple line of cdef is annotated as yellow in the html file. # my-file.pyx from cpython.array cimport array def f(double[:] xyz): cdef double[:] ...
nos's user avatar
  • 20.8k
1 vote
1 answer
62 views

Lackluster performance using inlined function in cython memoryview

I wrote the following Cython code that calculates pairwise distances à la scipy.spatial.distance.cdist. # cython: infer_types=True # cython: boundscheck=False # cython: wraparound=False cimport numpy ...
mueslo's user avatar
  • 717
2 votes
1 answer
417 views

Maximizing the speed of Cython array operations when using typed memory views and BLAS

I'm trying to maximize the speed of my Cython 3.0 code that involves updating an array with a loop of several array operations (including matrix-vector multiplication, vector-vector addition, and ...
Eric's user avatar
  • 35
0 votes
1 answer
90 views

Cython: How to convert numpy 2D array of type "object" to memoryview?

I am wondering how one can convert a 2D numpy array input of type "object" into a Cython memoryview? For example, if I have the following Cython extension type: cdef class A: cdef: ...
ajl123's user avatar
  • 1,252
1 vote
1 answer
96 views

Cython: safe way to check whether element in malloc memoryview is assigned

I want to create various small memoryviews in function temporarily and release them when the function is finished. Seems initialize the memoryview by malloc is better, based on the comparisons ...
Elkan's user avatar
  • 606
2 votes
0 answers
1k views

Cython vs. Pure Python with Memoryviews

I'm just starting to learn Cython and I'm confused on an issue. If you look at the main tutorial they have examples that show a "Pure Python" mode vs. "Cython" mode. The pure ...
Eric C.'s user avatar
  • 376
2 votes
1 answer
284 views

Cython: Casting vector of C++ `std::complex<double>` to C `double complex`

In Cython, starting from a C++ vector of std::complex<double> like this... # Imports from libcpp.vector cimport vector from libcpp.complex cimport complex as cpp_complex ctypedef my_complex = ...
ibarrond's user avatar
  • 7,491
1 vote
1 answer
216 views

Cython memoryview shape incorrect?

Consider the following to create a linear array of size 4: import numpy as np cimport numpy as np cdef np.float64_t [:] a = np.zeros(shape=(4),dtype=np.float64) a.shape should be (4,). However: print(...
Lucas Ng's user avatar
  • 661
0 votes
1 answer
91 views

Cython pyx modification for multidimensional numpy input with memory views

My current input of a function wrapped from a c++ class is a one dimensional numpy array, e.g., func(np.array([1,2,3])) for which my cython description in the pyx looks like the following: def func(...
Alejandro's user avatar
  • 949

15 30 50 per page
1
2 3 4 5 6