@@ -176,32 +176,31 @@ def compute_J(self, f=None, Ainv=None):
176176 sub_blocks = np .array_split (np .arange (n_data ), n_blocks )
177177
178178 for i_block , block_ind in enumerate (sub_blocks ):
179-
180179 if field_derivatives is None :
181180 batch_block .append (self .field_derivs [tInd + 1 ][isrc ][0 ][:, block_ind ].toarray ())
182181 batch_map [isrc , i_block ] = (batch_count , count )
183182 else :
184- i_file , i_block = batch_map [isrc , i_block ]
185- batch_block .append (field_derivatives [i_file ][:, i_block : i_block + len (block_ind )])
183+ i_file , i_col = batch_map [isrc , i_block ]
184+ batch_block .append (field_derivatives [i_file ][:, i_col :( i_col + len (block_ind ) )])
186185
187186 batch_indices .append ((isrc , block_ind ))
188187 block_count += 1
189-
188+ count += len ( block_ind )
190189 if block_count >= cpu_count ():
191190 f_blocks , j_blocks = process_blocks (
192191 self , AdiagTinv , d_count , batch_block , batch_indices , Asubdiag , f , tInd ,
193192 solution_type , Jmatrix
194193 )
195194 field_deriv_blocks .append (dask .array .hstack (f_blocks ))
196- j_row_blocks . append ( j_blocks )
195+ j_row_blocks += j_blocks
197196
198197 batch_block , batch_indices = [], []
199198 block_count = 0
200199 batch_count += 1
201200 d_count += count
202201 count = 0
203202
204- count += len ( block_ind )
203+
205204 # if isrc not in field_derivatives:
206205 # ATinv_df_duT_v = (
207206 # AdiagTinv * self.field_derivs[tInd + 1][isrc][0][:, block_ind].toarray()
@@ -214,7 +213,7 @@ def compute_J(self, f=None, Ainv=None):
214213 solution_type , Jmatrix
215214 )
216215 field_deriv_blocks .append (dask .array .hstack (f_blocks ))
217- j_row_blocks . append ( j_blocks )
216+ j_row_blocks += j_blocks
218217 del field_derivatives
219218
220219 if self .store_sensitivities == "disk" :
@@ -249,7 +248,11 @@ def process_blocks(
249248 self , AdiagTinv , d_count , batch_block , batch_indices , Asubdiag , f , tInd ,
250249 solution_type , Jmatrix
251250 ):
252- ATinv_df_duT_v = AdiagTinv * np .hstack (batch_block )
251+ rhs = np .asarray (np .hstack (batch_block ))
252+ if rhs .shape [1 ] < 1 :
253+ return [], []
254+
255+ ATinv_df_duT_v = AdiagTinv * rhs
253256 field_blocks = []
254257 j_row_blocks = []
255258 count = 0
@@ -258,7 +261,7 @@ def process_blocks(
258261 field_blocks .append (
259262 dask .array .from_delayed (
260263 delayed (parallel_field_deriv , pure = True )(
261- ATinv_df_duT_v [:, count : count + block_size ], Asubdiag ,
264+ ATinv_df_duT_v [:, count : ( count + block_size ) ], Asubdiag ,
262265 self .field_derivs [tInd ][indices [0 ]][0 ][:, indices [1 ]]
263266 ),
264267 shape = (Asubdiag .shape [0 ], block_size ),
@@ -269,7 +272,7 @@ def process_blocks(
269272 delayed (parallel_block_compute , pure = True )(
270273 self , f ,
271274 self .survey .source_list [indices [0 ]],
272- ATinv_df_duT_v [:, count : count + block_size ],
275+ ATinv_df_duT_v [:, count : ( count + block_size ) ],
273276 tInd ,
274277 solution_type ,
275278 d_count ,
0 commit comments