Passing to a pointer to a Cython extension class

I'm new to Keaton, so bear with me. I am trying to pass some data to a pointer to an extension class. The class is essentially an illustrious structure. It is declared in my .pxd file as:

cdef class Field:

    cdef:
        np.float64_t u                   # x velocity
        np.float64_t v                   # y velocity
        np.float64_t w                   # z velocity

    cdef update(self)

And of course, this is implemented in the .pyx file. In my driver code, I have a 4-dimensional array np.float64_t. The first three dimensions are x, y, and z. The fourth dimension should represent these three values u, v, w. I highlight the grid in a clean Python driver program, which then passes the grid to a Cython file. In the Cython file, I said:

curr_grid_element = (<Field *> &grid[xx, yy, zz, 0])
curr_grid_element.update()

But when I do, I get an error: Pointer base type cannot be a Python object.

Which scares me since I thought it Fieldwas pure C.

+4
1

Cython c-, python . , Field - python, , , C, , list ndarray. cython c- , , . (, ).

, , . :

cdef struct Field:
    np.float64_t u                   # x velocity
    np.float64_t v                   # y velocity
    np.float64_t w                   # z velocity
+2

Source: https://habr.com/ru/post/1616129/


All Articles