In python, with a NDarray of uint8s, how could I iterate over the array, and at indexes contained in a secondary NDarray, swap the LSB of the integer with the value from a third NDarray, containing only binary values, assuming all arrays have correct number of values.
What have you tried? Ignore the secondary array for a minute; do you know how to swap the LSBs unconditionally?
2026-01-12 23:36:47 +00:00
Commented 7 hours ago
Please give some example input and desired output so we have material to test possible answers. It doesn't need to be your real data; just a handful of numbers would do.
2026-01-12 23:37:20 +00:00
Commented 7 hours ago
"iterate over the array" - If you're talking about using a for-loop, that's actually an anti-pattern for NumPy. You should use array operations instead. I can show you once you give an example.
2026-01-12 23:39:35 +00:00
Commented 7 hours ago
Specifically, the details I'm looking for are: 1) Are the indexes given as ints (or tuples of ints), or as a boolean mask? 2) What do you mean by "binary"? booleans? Reference: minimal reproducible example
2026-01-12 23:44:14 +00:00
Commented 7 hours ago