[Numpy-discussion] ix_ and copies

Keith Goodman kwgoodman at gmail.com
Sun May 30 10:25:25 EDT 2010


On Sat, May 29, 2010 at 2:49 PM, Anne Archibald
<aarchiba at physics.mcgill.ca> wrote:
> On 29 May 2010 15:09, Robert Kern <robert.kern at gmail.com> wrote:
>> On Sat, May 29, 2010 at 12:27, Keith Goodman <kwgoodman at gmail.com> wrote:
>>> Will making changes to arr2 never change arr1 if
>>>
>>> arr2 = arr1[np.ix_(*lists)]
>>>
>>> where lists is a list of (index) lists? np.ix_ returns a tuple of
>>> arrays so I'm guessing (and hoping) the answer is yes.
>>
>> Correct.
>
> To expand: any time you do fancy indexing - that is, index by anything
> but a tuple of integers or slice objects - you get back a copy.

I have never seen such a simple and clear definition of the line
between regular and fancy indexing.

To make sure I understand I'll try to expand. Is the following right?

Regular indexing (no copy made):
int
float
bool
slice
tuple of any combination of the above

Fancy indexing (copy made):
Any indexing that is not regular indexing



More information about the NumPy-Discussion mailing list