np.where not returning expected results when applied to masked array in NumPy 1.24.3
I recently switched to I've been banging my head against this for hours... I'm attempting to set up I'm working with a masked NumPy array and trying to use `np.where` to identify elements that meet a certain condition. However, the output isn't what I expected. Here's a simplified version of what I've tried: ```python import numpy as np # Create a masked array with some masked values data = np.ma.array([1, 2, 3, 4, 5], mask=[0, 1, 0, 0, 1]) # Use np.where to find indices where the values are greater than 2 indices = np.where(data > 2) print(indices) ``` I expected `np.where` to return the indices of values greater than 2, which should be the indices 3 (value 4). Instead, I only get the indices for the unmasked values that meet the condition. The output is `(array([3]),)` as expected, but when I try to use these indices to get the actual values from the masked array: ```python values = data[indices] print(values) ``` I receive the output `masked_array(data=[4], mask=False, fill_value=999999)`, indicating that the masked array is returning the correct value, but I find it confusing that the `np.where` call seems to ignore the masked values entirely, and I don't know if this is intended behavior. Is there a better way to handle this situation, or am I misunderstanding how `np.where` interacts with masked arrays? I want to get the actual values while accounting for the masks. Any insights would be greatly appreciated! For reference, this is a production microservice. Any suggestions would be helpful. This is happening in both development and production on Ubuntu 22.04. What's the correct way to implement this? I've been using Python for about a year now. Am I missing something obvious? The project is a web app built with Python. Could someone point me to the right documentation? Any suggestions would be helpful.