def test_where_type_promotion(self): result = where([True, False], [1, 2], ['a', 'b']) assert_array_equal(result, np.array([1, 'b'], dtype=object)) result = where([True, False], np.array([1, 2], np.float32), np.nan) assert result.dtype == np.float32 assert_array_equal(result, np.array([1, np.nan], dtype=np.float32))
def test_where_type_promotion(self): result = where([True, False], [1, 2], ['a', 'b']) assert_array_equal(result, np.array([1, 'b'], dtype=object)) result = where([True, False], np.array([1, 2], np.float32), np.nan) assert result.dtype == np.float32 assert_array_equal(result, np.array([1, np.nan], dtype=np.float32))
def test_where(): from xarray.core.duck_array_ops import where data = cp.zeros(10) output = where(data < 1, 1, data).all() assert output assert isinstance(output, cp.ndarray)