[NumPy-Tickets] [NumPy] #1699: Failure assigning ctypes arrays to numpy arrays of size 1 on Py3

NumPy Trac numpy-tickets@scipy....
Mon Dec 20 14:57:56 CST 2010


#1699: Failure assigning ctypes arrays to numpy arrays of size 1 on Py3
-----------------------------------------+----------------------------------
 Reporter:  ulfw                         |       Owner:  somebody   
     Type:  defect                       |      Status:  new        
 Priority:  normal                       |   Milestone:  Unscheduled
Component:  numpy.core                   |     Version:  1.5.0      
 Keywords:  array size slice assignment  |  
-----------------------------------------+----------------------------------

Comment(by pv):

 The problem is this:
 {{{
 >>> import ctypes
 >>> x = (ctypes.c_double*1)()
 >>> y = memoryview(x)
 >>> y.shape
 (1,)
 >>> y.format
 '(1)<d'
 >>> import ctypes
 >>> x = (ctypes.c_double*2)()
 >>> y = memoryview(x)
 >>> y.shape
 (2,)
 >>> y.format
 '(2)<d'
 }}}
 It's a bug in `ctypes` on Python 3.

 In contrast to this:
 {{{
 >>> import numpy as np
 >>> x = numpy.array([1], dtype=float)
 >>> y = memoryview(x)
 >>> y.shape
 (1,)
 >>> y.format
 'd'
 }}}

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1699#comment:2>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list