()
| 1978 | |
| 1979 | |
| 1980 | def test_where_bool_optimization(): |
| 1981 | rng = np.random.default_rng() |
| 1982 | x = rng.integers(10, size=(15, 16)) |
| 1983 | d = da.from_array(x, chunks=(4, 5)) |
| 1984 | y = rng.integers(10, size=(15, 16)) |
| 1985 | e = da.from_array(y, chunks=(4, 5)) |
| 1986 | |
| 1987 | for c in [True, False, np.True_, np.False_, 1, 0]: |
| 1988 | w1 = da.where(c, d, e) |
| 1989 | w2 = np.where(c, x, y) |
| 1990 | |
| 1991 | assert_eq(w1, w2) |
| 1992 | |
| 1993 | ex_w1 = d if c else e |
| 1994 | |
| 1995 | assert w1 is ex_w1 |
| 1996 | |
| 1997 | |
| 1998 | def test_where_nonzero(): |