@@ -499,31 +499,33 @@ def adaptive_pixel_signals_from(
499499 M_sub , B = pix_indexes_for_sub_slim_index .shape
500500
501501 # 1) Flatten the per‐mapping tables:
502- flat_pixidx = pix_indexes_for_sub_slim_index .reshape (- 1 ) # (M_sub*B,)
503- flat_weights = pixel_weights .reshape (- 1 ) # (M_sub*B,)
502+ flat_pixidx = pix_indexes_for_sub_slim_index .reshape (- 1 ) # (M_sub*B,)
503+ flat_weights = pixel_weights .reshape (- 1 ) # (M_sub*B,)
504504
505505 # 2) Build a matching “parent‐slim” index for each flattened entry:
506- I_sub = jnp .repeat (jnp .arange (M_sub ), B ) # (M_sub*B,)
506+ I_sub = jnp .repeat (jnp .arange (M_sub ), B ) # (M_sub*B,)
507507
508508 # 3) Mask out any k >= pix_size_for_sub_slim_index[i]
509- valid = ( I_sub < 0 ) # dummy to get shape
509+ valid = I_sub < 0 # dummy to get shape
510510 # better:
511511 valid = (jnp .arange (B )[None , :] < pix_size_for_sub_slim_index [:, None ]).reshape (- 1 )
512512
513513 flat_weights = jnp .where (valid , flat_weights , 0.0 )
514- flat_pixidx = jnp .where (valid , flat_pixidx , pixels ) # send invalid indices to an out-of-bounds slot
514+ flat_pixidx = jnp .where (
515+ valid , flat_pixidx , pixels
516+ ) # send invalid indices to an out-of-bounds slot
515517
516518 # 4) Look up data & multiply by mapping weights:
517519 flat_data_vals = adapt_data [slim_index_for_sub_slim_index ][I_sub ] # (M_sub*B,)
518- flat_contrib = flat_data_vals * flat_weights # (M_sub*B,)
520+ flat_contrib = flat_data_vals * flat_weights # (M_sub*B,)
519521
520522 # 5) Scatter‐add into signal sums and counts:
521- pixel_signals = jnp .zeros ((pixels + 1 ,)).at [flat_pixidx ].add (flat_contrib )
522- pixel_counts = jnp .zeros ((pixels + 1 ,)).at [flat_pixidx ].add (valid .astype (float ))
523+ pixel_signals = jnp .zeros ((pixels + 1 ,)).at [flat_pixidx ].add (flat_contrib )
524+ pixel_counts = jnp .zeros ((pixels + 1 ,)).at [flat_pixidx ].add (valid .astype (float ))
523525
524526 # 6) Drop the extra “out-of-bounds” slot:
525527 pixel_signals = pixel_signals [:pixels ]
526- pixel_counts = pixel_counts [:pixels ]
528+ pixel_counts = pixel_counts [:pixels ]
527529
528530 # 7) Normalize
529531 pixel_counts = jnp .where (pixel_counts > 0 , pixel_counts , 1.0 )
@@ -532,7 +534,7 @@ def adaptive_pixel_signals_from(
532534 pixel_signals = jnp .where (max_sig > 0 , pixel_signals / max_sig , pixel_signals )
533535
534536 # 8) Exponentiate
535- return pixel_signals ** signal_scale
537+ return pixel_signals ** signal_scale
536538
537539
538540def mapping_matrix_from (
@@ -652,27 +654,27 @@ def mapped_to_source_via_mapping_matrix_from(
652654 mapping_matrix : np .ndarray , array_slim : np .ndarray
653655) -> np .ndarray :
654656 """
655- Map a masked 2D image (in slim form) into the source plane by summing and averaging
656- each image-pixel's contribution to its mapped source-pixels.
657-
658- Each row i of `mapping_matrix` describes how image-pixel i is distributed (with
659- weights) across the source-pixels j. `array_slim[i]` is then multiplied by those
660- weights and summed over i to give each source-pixel’s total mapped value; finally,
661- we divide by the number of nonzero contributions to form an average.
662-
663- Parameters
664- ----------
665- mapping_matrix : ndarray of shape (M, N)
666- mapping_matrix[i, j] ≥ 0 is the weight by which image-pixel i contributes to
667- source-pixel j. Zero means “no contribution.”
668- array_slim : ndarray of shape (M,)
669- The slimmed image values for each image-pixel i.
670-
671- Returns
672- -------
673- mapped_to_source : ndarray of shape (N,)
674- The averaged, mapped values on each of the N source-pixels.
675- """
657+ Map a masked 2D image (in slim form) into the source plane by summing and averaging
658+ each image-pixel's contribution to its mapped source-pixels.
659+
660+ Each row i of `mapping_matrix` describes how image-pixel i is distributed (with
661+ weights) across the source-pixels j. `array_slim[i]` is then multiplied by those
662+ weights and summed over i to give each source-pixel’s total mapped value; finally,
663+ we divide by the number of nonzero contributions to form an average.
664+
665+ Parameters
666+ ----------
667+ mapping_matrix : ndarray of shape (M, N)
668+ mapping_matrix[i, j] ≥ 0 is the weight by which image-pixel i contributes to
669+ source-pixel j. Zero means “no contribution.”
670+ array_slim : ndarray of shape (M,)
671+ The slimmed image values for each image-pixel i.
672+
673+ Returns
674+ -------
675+ mapped_to_source : ndarray of shape (N,)
676+ The averaged, mapped values on each of the N source-pixels.
677+ """
676678 # weighted sums: sum over i of array_slim[i] * mapping_matrix[i, j]
677679 # ==> vector‐matrix multiply: (1×M) dot (M×N) → (N,)
678680 mapped_to_source = array_slim @ mapping_matrix
@@ -722,4 +724,3 @@ def data_weight_total_for_pix_from(
722724
723725 # Sum weights by pixel index
724726 return np .bincount (flat_idxs , weights = flat_weights , minlength = pixels )
725-
0 commit comments