@@ -164,16 +164,13 @@ def cond_fun(k):
164164 i = idx [idx_i ]
165165 bin_to_calculate = jax .lax .while_loop (cond_fun , lambda k : k + 1 , 0 )
166166 return bin_to_calculate
167- # TODO: what happens if k == x_bins.shape[0] - 1
168167
169168 new_moment_0 = jax .numpy .zeros ((moment_0 .shape [0 ]+ 1 , moment_0 .shape [1 ]))
170169 new_moments = jax .numpy .zeros ((moment_0 .shape [0 ]+ 1 , moment_0 .shape [1 ]))
171170 idx_idxs = jax .numpy .arange (length )
172171
173172 count_bins_func = jax .vmap (spectrum_moments_helper , (None , None , None , 0 ))
174173 bins_to_count = count_bins_func (x_bins .data , x_attr .data , idx .data , idx_idxs )
175- # TODO: bins_to_count > len()-1 is not handled
176- print (bins_to_count )
177174 assert all (bins_to_count < new_moments .shape [0 ])
178175 mapped_spectrum = jax .vmap (self ._spectrum_moments_body , (None , None , None , None , None , None , None , None , None , 0 , 0 ))
179176
@@ -191,10 +188,8 @@ def cond_fun(k):
191188 idx_idxs
192189 )
193190
194- # moments.data = new_moments.sum(0)
195- # moment_0.data = new_moment_0.sum(0)
196- moments .data = new_moments .at [:- 1 , :].sum (0 )
197- moment_0 .data = new_moment_0 .at [:- 1 , :].sum (0 )
191+ moments .data = jax .numpy .sum (new_moments [:, :- 1 , :], axis = 0 )
192+ moment_0 .data = jax .numpy .sum (new_moment_0 [:, :- 1 , :], axis = 0 )
198193
199194 if not skip_division_by_m0 :
200195 moments .data = jax .numpy .where (moment_0 .data != 0 , moments .data / moment_0 .data , 0.0 )
0 commit comments