where is the error?

John Machin sjmachin at lexicon.net
Fri Jun 27 15:23:56 CEST 2008


On Jun 27, 10:12 pm, la... at caramail.com wrote:
> There was an error with the name of the variable !!!! I would not ask
> this if it was just a question of different variable names !!!!!
>

Calm down. Stop shouting. It is not evident whether the above means
that diff_temp_Stumpf was an error (should have been merely diff_temp)
or not.

> diff_temp=(logical_and(values[:,5] > -2,values[:,5] < 2)).nonzero()
> new_values=values[diff_temp,:]
>
> Okay, I'm going to try to explain that more specifically that I did. I
> have an array called values (size mxn). In this database, I just want
> the lines for which the values of the nth row are between two values
> (it's the purpose of diff_temp). So diff_temp gets me the number of
> the lines for which this latter criteria is right.

I think that you mean that diff_temp will be an array of the numberS
(plural) of the lines (rows?) in values array that met the -2 < x < 2
criterion. Now you want to be able to use diff_temp to get the
corresponding subset of some other array. Am I getting close?

>
 But I'm interested
> on the values of the lines corresponding to the number given by
> diff_temp.

Now you want to be able to use diff_temp to get the corresponding
subset of some other array. Am I getting close?

Perhaps you need something like other_array.take(diff_temp) ?

>
> In matlab, I will do
>
> diff_temp=find(values(:,5) > -2 & values[:,5) <2)
>
> new_values=values(diff_temp,:)
>
> Is it clear?

Not very, I don't grok matlab.

By the way, shouldn't you be using numpy? I thought numarray was going
away by mid-2008 i.e. now.

HTH,
John





> Thanks
> Cedric




More information about the Python-list mailing list