[Numpy-discussion] PyArray_Resize with scipy.weave

2008-06-04 Thread Orest Kozyar
The following code fails: from scipy import weave from numpy import zeros arr = zeros((10,2)) code = """ PyArray_Dims dims; dims.len = 2; dims.ptr = Narr; dims.ptr[0] += 10; PyArray_Resize(arr_array, &dims, 1); """ weave.inline(code, ['arr'], verbose=1) The error message is: In function 'PyObjec

Re: [Numpy-discussion] numpy.ndarray.astype conversion

2008-05-24 Thread Orest Kozyar
> > The following line: array([6.95e-5]).astype('S') > > returns: array(['6'], dtype='|S1') > I don't know what it should do. Issue a warning, maybe? > What are you trying to do? At the very least a warning would not hurt. When I first started using the numpy arrays it looked like conversion to

[Numpy-discussion] numpy.ndarray.astype conversion

2008-05-22 Thread Orest Kozyar
The following line: array([6.95e-5]).astype('S') returns: array(['6'], dtype='|S1') I realize that I can get it to return the correct string representation if I specify 'S12', etc, but anything below 'S9' results in an incorrect string representation of the number. Is this expected behavior? Th

Re: [Numpy-discussion] Slicing a numpy array and getting the "complement"

2008-05-19 Thread Orest Kozyar
> If you don't mind fancy indexing, you can convert your index arrays > into boolean form: > complement = A==A > complement[idx] = False This actually would work perfectly for my purposes. I don't really need super-fancy indexing. >> Given a slice, such as s_[..., :-2:], is it possible to take t

[Numpy-discussion] Slicing a numpy array and getting the "complement"

2008-05-19 Thread Orest Kozyar
Given a slice, such as s_[..., :-2:], is it possible to take the complement of this slice? Specifically, s_[..., ::-2]. I have a series of 2D arrays that I need to split into two subarrays via slicing where the members of the second array are all the members leftover from the slice. The problem

[Numpy-discussion] odd behavior for numpy.ndarray index?

2007-09-09 Thread Orest Kozyar
In the following output (see below), why would x[1,None] work, but x[1,None,2] or even x[1,2,None] not work? Incidentally, I would be very interested in a solution that allows me to index numpy arrays using a list/iterable that might contain None values. Is there a straightforward way to do so,