Is there any way to detect whether one array is a view into another
array? I'd like something like:
arr = N.arange(5)
subarr = arr[1:3]
sharesdata(arr, subarr)
True
-- Matt
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
Pierre GM wrote:
On Wednesday 11 April 2007 18:12:16 Matthew Koichi Grimes wrote:
Is there any way to detect whether one array is a view into another
array? I'd like something like:
arr = N.arange(5)
subarr = arr[1:3]
sharesdata(arr, subarr)
Mmh, would arr.flags['OWNDATA'] would
If there are no objections, I'll file this ticket in the trac site:
snip
Title:
Return type inconsistency in recarray
Description:
The sub-arrays of rank-0 recarrays are returned as scalars rather than
rank-0 ndarrays.
Example:
import numpy as N
dt = N.dtype([('x','f8'),('y','f8')])
rarr
Francesc Altet wrote:
with a
rank-0 'recarr', 'recarr.x' should return a rank-0 array (for
consistency), but it doesn't:
In [74]:recarr=numpy.rec.array((1.0, 0, 3), dtype)
In [75]:recarr.x
Out[75]:1.0
In [76]:type(recarr.x)
Out[76]:type 'numpy.float64'
While I find this inconsistent,
I would like to twiddle with the strides of a matrix such that the rows
overlap each other. I've gotten this far:
In [1]: import numpy as N
In [2]: mat = N.arange(12).reshape(3,4)
In [3]: mat
Out[3]:
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
In [4]:
Numpy's any() function gives unintuitive results when given a generator
rather than a sequence:
import numpy as N
N.any( i 0 for i in range(3) )
True
If the generator is instead given as a list (using a list
comprehension), then the expected answer is given:
N.any( [i 0 for i in range(3)]