apply_fill_on_write

swxsoc.io.fillval.apply_fill_on_write(arr: ndarray, mask: ndarray, fillval: Any) ndarray[source]

Return a copy of arr with fill positions replaced by fillval.

Fill positions are the union of:

  • mask (when provided),

  • NaN values (float arrays only),

  • the literal bytes b"nan" / b"NaN" (string arrays only; write-side convenience for users who pass np.nan into an S or U array, which numpy coerces to the bytes b"nan").

Parameters:
  • arr (array-like) – Source data. Not mutated.

  • mask (array-like of bool, or None) – Explicit mask of fill positions. Broadcast-compatible with arr.

  • fillval (scalar or None) – The variable’s FILLVAL attribute. If None, arr is returned as a copy with no replacements.

Returns:

numpy.ndarray – A new array with fill positions replaced.