Brian McLaughlin wrote:
> If I do:
> t1=datetime.datetime(2008,06,02,01,0,0)
> t1=datetime.datetime(2008,06,02,02,0,0)
> tVec1=drange(t1,t2,datetime.timedelta(seconds=1))
> tVec2=drange(t1,t2,datetime.timedelta(seconds=5))
> tVec3=nan*ones(tVec1.shape)
> 
> I cannot do something like:
> for i in tVec2:
>   tVec3[where(tVec1==i)]=i

You don't need the "where", but you do need something like this:

     tVec3[fabs(tVec1 - i) < 1e-6]=i

Using perfect equality in floating point comparisons is usually wrong.

Eric

> 
> tVec3[0] is written, yet the others are not.
> 
> print tVec1[0]
>  > 733195.083333
> 
> print tVec1
>  >[ 733195.08333333  733195.08334491  733195.08335648 ...,   
> 733195.50376352
> 733195.5037751   733195.50378667]
> 
> There is more precision in the second statement and, I believe, the  
> result for no matches inside the for loop.
> Is this the desired behavior?
> 
> I can do:
> vec1=arange(0,100,1)
> vec2=arange(0,100,5)
> vec3=nan*ones(tVec1.shape)
> for i in vec2:
>   vec3[where(vec1==i)]=i
> 
> thanks,
> Brian
> 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to