Reported by scoder on 29 Jun 2015 13:40 UTC
As reported on the mailing list:
There seem to be some bugs regarding memoryviews of structured arrays
in Cython when the struct itself contains arrays. I have a Cython fix for
one of them (the most relevant to me), but first I would like to make sure
that these are really bugs and I am not doing anything stupid. This
question is related to
http://stackoverflow.com/questions/17239091/cython-memoryviews-from-array-of-structs,
but the answer there works only for char arrays. An array of doubles breaks
it again.
It seems to me that Cython implementation solves some special cases, but
not the general one. My proposed fix would be to insert
ndim = ctx->head->field->type->ndim;
after
/* Process the previous element */
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
in Cython\Utility\Buffer.c
This fixes tests 2, 4 and 7, but not 8 and 9 (see below). I am not sure
about the details of what the code in Buffer.c is supposed to do and
whether my modification would break some other functionality, but my code
(not only the tests) works with this fix.
Or am I possibly simply missing "the right way" to handle arrays of structs
containing arrays in Cython? But in either case the compiler shouldn't
crash like in test 9...
Here is the code of my tests with and without numpy with results ranging
from "ok" to "compiler crash".
The numpy tests require these imports:
Reported by scoder on 29 Jun 2015 13:40 UTC As reported on the mailing list:
There seem to be some bugs regarding memoryviews of structured arrays in Cython when the struct itself contains arrays. I have a Cython fix for one of them (the most relevant to me), but first I would like to make sure that these are really bugs and I am not doing anything stupid. This question is related to http://stackoverflow.com/questions/17239091/cython-memoryviews-from-array-of-structs, but the answer there works only for char arrays. An array of doubles breaks it again.
It seems to me that Cython implementation solves some special cases, but not the general one. My proposed fix would be to insert
after
in Cython\Utility\Buffer.c
This fixes tests 2, 4 and 7, but not 8 and 9 (see below). I am not sure about the details of what the code in Buffer.c is supposed to do and whether my modification would break some other functionality, but my code (not only the tests) works with this fix.
Or am I possibly simply missing "the right way" to handle arrays of structs containing arrays in Cython? But in either case the compiler shouldn't crash like in test 9...
Here is the code of my tests with and without numpy with results ranging from "ok" to "compiler crash". The numpy tests require these imports:
Migrated-From: http://trac.cython.org/ticket/853