advanced patterns with np.where returning incorrect indices for masked arrays in NumPy 1.24.2
I've been working on this all day and I recently switched to I'm dealing with I'm dealing with I'm experiencing unexpected behavior when using `np.where` on masked arrays in NumPy 1.24.2... I have a masked array where certain values are masked, and I want to get the indices of the unmasked values. The function seems to return indices that don't correspond to the expected unmasked values. Hereβs a minimal example: ```python import numpy as np # Create a masked array arr = np.ma.array([1, 2, 3, 4, 5], mask=[0, 1, 0, 1, 0]) # Attempt to find indices of unmasked values indices = np.where(~arr.mask)[0] print(indices) ``` This code snippet should return the indices of the unmasked elements, which are 0, 2, and 4. However, when I run this, I get: ``` array([0, 1, 2, 3, 4]) ``` This return seems to include all indices rather than just those of the unmasked elements. Iβve also tried using `np.ma.nonzero(arr)` and `np.ma.masked_where()` but still encountered similar issues. Am I misunderstanding how to properly work with masked arrays in this version of NumPy? Is there a different approach I should be using to extract the indices of the unmasked values instead? My development environment is Ubuntu. What am I doing wrong? This is part of a larger desktop app I'm building. The project is a CLI tool built with Python. My team is using Python for this web app. Hoping someone can shed some light on this. I'm working on a service that needs to handle this. I'd love to hear your thoughts on this.