<br><br><div class="gmail_quote">On Tue, Oct 2, 2012 at 11:43 AM, Charles R Harris <span dir="ltr"><<a href="mailto:charlesr.harris@gmail.com" target="_blank">charlesr.harris@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><br><div class="gmail_quote"><div><div class="h5">On Tue, Oct 2, 2012 at 11:30 AM, Frédéric Bastien <span dir="ltr"><<a href="mailto:nouiz@nouiz.org" target="_blank">nouiz@nouiz.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div>On Tue, Oct 2, 2012 at 1:18 PM, Charles R Harris<br>
<<a href="mailto:charlesr.harris@gmail.com" target="_blank">charlesr.harris@gmail.com</a>> wrote:<br>
><br>
><br>
> On Tue, Oct 2, 2012 at 9:45 AM, Frédéric Bastien <<a href="mailto:nouiz@nouiz.org" target="_blank">nouiz@nouiz.org</a>> wrote:<br>
>><br>
>> We implement our own subtensor(x[...], where ... can be index or<br>
>> slice) c code due to the way Theano work.<br>
>><br>
>> I can probably change the logic, but if you plan to revert this<br>
>> interface changes, I prefer to wait for this change we someone else is<br>
>> doing other changes that would conflict. Also, I did a Theano release<br>
>> candidate and I really would like the final version to work with the<br>
>> next release of NumPy.<br>
><br>
><br>
> Well, you don't *have* to define NPY_NO_DEPRECATED_API. If you don't you can<br>
> access the array as before using the macros even for future versions of<br>
> numpy. The only way that could cause a problems is if the array structure is<br>
> rearranged and I don't think that will happen anytime soon. On that account<br>
> there has not been any discussion of reverting the changes. However, I'd<br>
> like f2py generated modules to use the new functions at some point and in<br>
> order to do that numpy needs to supply some extra functionality, I'm just<br>
> not sure of the best way to do it at the moment. If I had a good idea of<br>
> what you want to do it would help in deciding what numpy should provide.<br>
<br>
</div></div>I do not define NPY_NO_DEPRECATED_API, so I get g++ warning about<br>
that. That is the problem I have.<br>
<br>
What I do is close to that:<br>
<br>
alloc a new ndarray that point to the start of the ndarray I want to<br>
view with the right number of output dimensions.<br>
<br>
Compute the new dimensions/strides and data ptr. Then set the data ptr<br>
to what I computed. Then set the base ptr.<br>
<br>
I can reverse this and create the ndarray only at the end, but as this<br>
change break existing code here, it can break more code. That is why I<br>
wrote to the list.<br>
<br>
doing "PyArray_BASE(xview) = ptr" work when I don't define<br>
NPY_NO_DEPRECATED_API, but do not work when I define<br>
NPY_NO_DEPRECATED_API. I would have expected the same for<br>
PyArray_BYTES/DATA.<br>
<br>
Do this explain clearly the problem I saw?<br>
<br></blockquote></div></div><div><br>Yes, thanks. I see in ndarraytypes.h<br><br>#define PyArray_DATA(obj) ((void *)(((PyArrayObject_fields *)(obj))->data))<br><br>I wonder if the cast to void* is causing a problem? Could you try char* instead?<br>
</div></div></blockquote><div><br>Oops, the problem is that you need a pointer to the slot, not the pointer in the slot. That is, you need a different macro/function.<br><br>Chuck <br></div></div>