()
| 2035 | |
| 2036 | |
| 2037 | def test_coerce(): |
| 2038 | d0 = da.from_array(np.array(1), chunks=(1,)) |
| 2039 | d1 = da.from_array(np.array([1]), chunks=(1,)) |
| 2040 | with dask.config.set(scheduler="sync"): |
| 2041 | for d in d0, d1: |
| 2042 | assert bool(d) is True |
| 2043 | assert int(d) == 1 |
| 2044 | assert float(d) == 1.0 |
| 2045 | assert complex(d) == complex(1) |
| 2046 | |
| 2047 | a2 = np.arange(2) |
| 2048 | d2 = da.from_array(a2, chunks=(2,)) |
| 2049 | for func in (int, float, complex): |
| 2050 | pytest.raises(TypeError, lambda func=func: func(d2)) |
| 2051 | |
| 2052 | |
| 2053 | def test_bool(): |