est.core.process.handle_nan.array_undo_mask#
- est.core.process.handle_nan.array_undo_mask(masked: ndarray, mask: ndarray) ndarray [source]#
Restore an array to its original shape after applying a boolean mask.
- Parameters:
masked – The array containing only the unmasked values.
mask – A boolean array indicating the original positions of the masked values.
- Returns:
A reconstructed array of the same shape as mask, where values from masked are restored to their original positions, and other elements are filled with NaN (for floats) or 0 (for ints).
Example:
>>> import numpy as np >>> original = np.array([1.0, 2.0, np.nan, 4.0, np.nan]) >>> mask = ~np.isnan(original) # Boolean mask >>> masked = original[mask] # Extract non-NaN values >>> restored = array_undo_mask(masked, mask) >>> print(restored) [ 1. 2. nan 4. nan ]