Matt
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 =
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
htt
Travis wrote:
>
> Short answer: No, they are not bugs.
>
> The rule is:
>
> In any mixed-type operation between two objects of the same
> fundamental "kind" (i.e. integer, float, complex) arrays always have
> precedence over "scalars" (where a 0-d array is considered a scalar
> in this context
I've noticed two dtype promotion behaviors that are surprising to me.
I'm hoping to get people's input as to whether I should file bug tickets
on them.
First weirdness:
When you do an operation between a float32 Numpy array and a python or
Numpy float64, the result is a float32 array, not a flo
If there are no objections, I'll file this ticket in the trac site:
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')])
>>>
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]:
>
> While I find this inconsistent, I'm not sure
I've found that if I have a record array of shape [] (i.e. a scalar
recarray), I can't set its fields.
>>> recarr
recarray((0.0, 0.0, 0.0),
dtype=[('x', '>> recarr.x[...] = 1.0
TypeError: object does not support item assignment
In the above, recarr.x returned a float "0.0", then attempted
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]: mat.strides
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
Pierre GM wrote:
> On Wednesday 03 January 2007 15:39, Matthew Koichi Grimes wrote:
>
>> As per Stefan's help, I've made a subclass of recarray called nnvalue.
>> It just fixes the dtype to [('x', 'f8'), ('dx', 'f8'), (&
As per Stefan's help, I've made a subclass of recarray called nnvalue.
It just fixes the dtype to [('x', 'f8'), ('dx', 'f8'), ('delta', 'f8)],
and adds a few member functions. I basically treat nnvalue as a struct
with three equal-shaped array fields: x, dx, and delta.
I'd like it if, when I re
Is it hard to subclass recarrays? I'm currently working on a subclass
that doesn't add much; just some methods that sets all the values to
zero and other similarly trivial things. It'd be nice to make it work,
but if I have to use external functions on a plain recarray instead of
this subclass
(Newbie alert.)
I'm having trouble making a nested record array. I'm trying to work from
the following example on the scipy.org examples page:
>>> mydescriptor = dtype([('x', 'f4'),('y', 'f4'), # nested recarray
... ('nested', [('i', 'i2'),('j','i2')])])
>>> myarr = array([(1.0, 2.0, (1,2)
13 matches
Mail list logo