File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed
autoarray/operators/over_sampling Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,6 @@ def slim_index_for_sub_slim_index_via_mask_2d_from(
123123
124124 return slim_index_for_sub_slim_index
125125
126- @numba_util .jit ()
127126def sub_size_radial_bins_from (
128127 radial_grid : np .ndarray ,
129128 sub_size_list : np .ndarray ,
@@ -161,19 +160,13 @@ def sub_size_radial_bins_from(
161160 the centre of the mask.
162161 """
163162
164- sub_size = sub_size_list [- 1 ] * np .ones (radial_grid .shape )
163+ # Use np.searchsorted to find the first index where radial_grid[i] < radial_list[j]
164+ bin_indices = np .searchsorted (radial_list , radial_grid , side = "left" )
165165
166- for i in range (radial_grid .shape [0 ]):
167- for j in range (len (radial_list )):
168- if radial_grid [i ] < radial_list [j ]:
169- # if use_jax:
170- # # while this makes it run, it is very, very slow
171- # sub_size = sub_size.at[i].set(sub_size_list[j])
172- # else:
173- sub_size [i ] = sub_size_list [j ]
174- break
166+ # Clip indices to stay within bounds of sub_size_list
167+ bin_indices = np .clip (bin_indices , 0 , len (sub_size_list ) - 1 )
175168
176- return sub_size
169+ return sub_size_list [ bin_indices ]
177170
178171
179172@numba_util .jit ()
You can’t perform that action at this time.
0 commit comments