Open
Description
Please provide a description of what you'd like to do.
More dependable fill_value preservation in where
Example Code
import sparse
import numpy as np
array = sparse.COO.from_numpy(np.eye(3), fill_value=0)
assert np.where(array == 1, np.nan, array).fill_value == 0 # passes
assert np.where(array < 1, np.nan, array).fill_value == 0 # fails, result fill_value is np.nan
For mask=array==1
, mask.fill_value=False
and the array
's fill_value is preserved in the np.where call.
For mask=array<1
, mask.fill_value=True
and the array
's fill_value is NOT preserved in the np.where call.
This kind of behaviour is hard to rely on in a library. Is it a bug?