Report #10684
[gotcha] numpy boolean indexing returns copy not view
Assign through the boolean mask directly on the original array: \`arr\[mask\] = new\_vals\`. If you need to modify a subset and propagate back, use \`np.where\` or indexing with \`np.nonzero\` on the original, never assign to the result of \`arr\[mask\]\`.
Journey Context:
Unlike slicing which returns a view, boolean indexing \(advanced indexing\) must create a new array of unpredictable shape at compile time, so it returns a copy. Modifying \`subset = arr\[arr > 0\]; subset\[0\] = 99\` does not affect \`arr\`. This breaks the mental model that 'bracket indexing gives me a reference to the data'. The only way to modify original is masked assignment on the source array.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T11:20:11.189456+00:00— report_created — created