()
| 1878 | |
| 1879 | |
| 1880 | def test_where_bool_optimization(): |
| 1881 | rng = np.random.default_rng() |
| 1882 | x = rng.integers(10, size=(15, 16)) |
| 1883 | d = da.from_array(x, chunks=(4, 5)) |
| 1884 | y = rng.integers(10, size=(15, 16)) |
| 1885 | e = da.from_array(y, chunks=(4, 5)) |
| 1886 | |
| 1887 | for c in [True, False, np.True_, np.False_, 1, 0]: |
| 1888 | w1 = da.where(c, d, e) |
| 1889 | w2 = np.where(c, x, y) |
| 1890 | |
| 1891 | assert_eq(w1, w2) |
| 1892 | |
| 1893 | ex_w1 = d if c else e |
| 1894 | |
| 1895 | assert w1 is ex_w1 |
| 1896 | |
| 1897 | |
| 1898 | def test_where_nonzero(): |