memoryview (np.asarray) on struct with bitfields

18 views
Skip to first unread message

Brent Pedersen

unread,
Apr 26, 2019, 12:19:05 PM4/26/19
to cython-users
Hi, I have this C struct:

typedef struct {
  uint8_t reverse_strand:1, base: 7;
} basestrand_t;

and I'm trying to access it as:

     dt = np.dtype([('reverse_strand', np.bool, 1), ('base', np.byte, 1)])
     cdef np.uint8_t *bs = <np.uint8_t *>self.c.bases
     return np.asarray(<np.uint8_t[:self.c.n]>bs, dtype=dt)

but it seems 1. that maybe numpy doesn't support dtypes with bitfields or 2. I am doing something incorrectly.

Either way, is there a way that I can get a view into an array of this type of struct?
thanks,
-Brent
Reply all
Reply to author
Forward
0 new messages