I can't explain why this changed in numpy or why PyArray_FromDims works 
and PyArray_SimplyNewFromData doesn't, but...

In _backend_agg.cpp, I just used a npy_intp array for dimensions 
everywhere.  I think the difference may only matter on 64 platforms 
where sizeof(int) != sizeof(void*), such as x86_64.  npy_intp is a 
typedef for Py_intptr_t which is defined thusly (in pyport.h):

*/* uintptr_t is the C9X name for an unsigned integral type such that a
 * legitimate void* can be cast to uintptr_t and then back to void* again
 * without loss of information.  Similarly for intptr_t, wrt a signed
 * integral type.
 */
*
Cheers,
Mike

John Hunter wrote:
>> On Thu, Jun 12, 2008 at 2:54 PM, Nils Wagner
>> <[EMAIL PROTECTED]> wrote:
>>
>>     
>>> src/ft2font.cpp: In member function 'Py::Object FT2Image::py_as_array(const
>>> Py::Tuple&)':
>>> src/ft2font.cpp:273: error: cannot convert 'int*' to 'npy_intp*' in argument
>>> passing
>>> error: command 'gcc' failed with exit status 1
>>>       
>
> Hmm, I had tried to use PyArray_SimpleNewFromData with an 'int
> dimensions[2]' array, which worked on numpy 1.1 but apparently breaks
> in the latest numpy svn.  Since I am unsure what is the most portable
> thing to do here, I reverted to a pattern that we've used elsewhere
> that appears robust across numpy versions (included below).  If any
> numpy god wants to tell me the right way to create and array from an
> existing buffer, let me know.
>
> Fixed in svn 5495
>
>
>  int dimensions[2];
>  dimensions[0] = get_height();  //numrows
>  dimensions[1] = get_width();   //numcols
>
>  //this is breaking with numpy svn, which wants a npy_intp*
>  //PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNewFromData(2,
> dimensions, PyArray_UBYTE, _buffer);
>
>
> PS: please keep all replies on list.
>  PyArrayObject *A = (PyArrayObject *) PyArray_FromDims(2, dimensions,
> PyArray_UBYTE);
>
>
>  unsigned char *src            = _buffer;
>  unsigned char *src_end        = src + (dimensions[0] * dimensions[1]);
>  unsigned char *dst            = (unsigned char *)A->data;
>
>  while (src != src_end) {
>    *dst++ = *src++;
>  }
>
>
> PS: please keep all replies on list
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Matplotlib-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>   

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to