implementing np.where returning incorrect indices when using masked arrays in NumPy 1.25
I just started working with I'm wondering if anyone has experience with I'm working with unexpected behavior when using `np.where` with masked arrays in NumPy 1.25... I have a masked array where certain values are invalid (masked), and I expect `np.where` to return the indices of the unmasked values. However, it seems to return indices that do not correspond to the expected unmasked elements. Here's a minimal example: ```python import numpy as np # Creating a masked array with some invalid (masked) values data = np.array([1, 2, 3, 4, 5]) masked_data = np.ma.masked_array(data, mask=[0, 1, 0, 1, 0]) # Using np.where on the masked array indices = np.where(~masked_data.mask)[0] print(indices) # Expecting to see [0, 2, 4] ``` Instead of the expected result, I get an output of `array([0, 1, 2, 3, 4])`, which includes indices of the masked values as well. I tried using `masked_data.compressed()` to get just the unmasked values, but that doesn't help with the indices directly. I also checked the documentation for `np.where`, but it seems like it should respect the mask. Is there a different approach I should be using to get the correct indices of the unmasked values? Any insights would be appreciated! I'm working on a CLI tool that needs to handle this. I'd really appreciate any guidance on this. This is part of a larger service I'm building. How would you solve this? My development environment is Linux. I'd love to hear your thoughts on this. I'm developing on Ubuntu 20.04 with Python. Am I approaching this the right way?