Numeric question
Cameron Hooper
cameron at hooper.net
Sun Apr 28 22:00:19 EDT 2002
Chris Barker wrote:
>
>
> Emile van Sebille wrote:
>
>> OK. It's x. So let's build a contiguous x and try it again:
>
>> >>> x = array(inputs[0][:])
>
> or
>
> x = inputs[0][:].copy()
>
> The copy method isn't in the version of the docs I have, but it's very
> handy and quite clear as to what it is doing.
>
> or
>
> x = inputs[0,:].copy()
>
> Numpy arrays are N-dimensional, you might as well index them that way.
>
> come to think of it, why not:
>
> inputs[0].copy() ?
>
>
> -Chris
>
Thanks for the replies. So my understanding now is that the concatenate
function really combines two references to two separate locations in memory
into a single object. The two locations are not contiguous. Data is not
'moved around' so to speak. So x = concatenate(y,z) can be viewed as
returning a reference to two non-contiguous references. But x =
array(concatenate(y,z)) (or using copy()) actually copies data.
Cameron
More information about the Python-list
mailing list