I'm actively looking at this issue since it was my pull request that broke this (<a href="https://github.com/numpy/numpy/pull/350" target="_blank">https://github.com/numpy/numpy/pull/350</a>). We definitely don't want to break this functionality for 1.7. The problem is that even though indexing with a subset of fields still returns a copy (for now), it now returns a copy of a view of the original array. When you call copy() on a view, it copies the entire original structured array with the view dtype. A short term fix would be to "manually" create a proper copy to return similar to what _index_fields() did before my change, but since the idea is to eventually return the view instead of a copy, long term we need a way to do a proper copy of a structured array view that doesn't copy the unwanted fields.<div>


<br></div><div>-Jay<br><div>
<div><br><div class="gmail_quote">On Wed, Jul 25, 2012 at 10:15 AM, Skipper Seabold <span dir="ltr"><<a href="mailto:jsseabold@gmail.com" target="_blank">jsseabold@gmail.com</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 Sun, Jul 22, 2012 at 2:15 PM, Ralf Gommers<br>
<<a href="mailto:ralf.gommers@googlemail.com" target="_blank">ralf.gommers@googlemail.com</a>> wrote:<br>
> Hi,<br>
><br>
> Just a heads up that right now views of recarrays seem to be problematic,<br>
> this doesn't work anymore:<br>
><br>
>>>> import statsmodels.api as sm<br>
>>>> dta = sm.datasets.macrodata.load()  # returns a record array with 14<br>
>>>> fields<br>
>>>> dta.data[['infl', 'realgdp']].view((float,2))<br>
><br>
> I opened <a href="http://projects.scipy.org/numpy/ticket/2187" target="_blank">http://projects.scipy.org/numpy/ticket/2187</a> for this. Probably a<br>
> blocker for 1.7.0.<br>
><br>
> Question: is that really the recommended way to get an (N, 2) size float<br>
> array from two columns of a larger record array? If so, why isn't there a<br>
> better way? If you'd want to write to that (N, 2) array you have to append a<br>
> copy, making it even uglier. Also, then there really should be tests for<br>
> views in test_records.py.<br>
><br>
<br>
</div></div>Any comments on this? I have a lot of broken code to deal with if<br>
((float, shape[1])) is no longer allowed on structured and rec arrays.<br>
<br>
Skipper<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div><br></div></div>
</div>