Mercurial > hg > medcouple
comparison pymedcouple @ 6:e3b1dcc51e6a
Fix tee usage
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Tue, 13 Jan 2015 17:26:39 -0500 |
parents | cbe17f888c79 |
children | 6c7c7dc9d8ef |
comparison
equal
deleted
inserted
replaced
5:cbe17f888c79 | 6:e3b1dcc51e6a |
---|---|
156 | 156 |
157 # kth pair algorithm (Johnson & Mizoguchi) | 157 # kth pair algorithm (Johnson & Mizoguchi) |
158 while Rtot - Ltot > n_plus: | 158 while Rtot - Ltot > n_plus: |
159 | 159 |
160 # First, compute the median inside the given bounds | 160 # First, compute the median inside the given bounds |
161 I1 = (i for i in xrange(0, n_plus) if L[i] <= R[i]) | 161 # (Be stingy, reuse same generator) |
162 I2 = tee(I1) # Be stingy, reuse same generator | 162 [I1, I2] = tee(i for i in xrange(0, n_plus) if L[i] <= R[i]) |
163 | |
163 A = [h_kern(i, (L[i] + R[i])//2) for i in I1] | 164 A = [h_kern(i, (L[i] + R[i])//2) for i in I1] |
164 W = [R[i] - L[i] for i in I2] | 165 W = [R[i] - L[i] for i in I2] |
165 Am = wmedian(A,W) | 166 Am = wmedian(A,W) |
166 | 167 |
167 # Compute new left and right boundaries, based on the weighted | 168 # Compute new left and right boundaries, based on the weighted |