| 2253 | |
| 2254 | |
| 2255 | def test_store_compute_false(): |
| 2256 | d = da.ones((4, 4), chunks=(2, 2)) |
| 2257 | a, b = d + 1, d + 2 |
| 2258 | |
| 2259 | at = np.zeros(shape=(4, 4)) |
| 2260 | bt = np.zeros(shape=(4, 4)) |
| 2261 | |
| 2262 | v = store([a, b], [at, bt], compute=False) |
| 2263 | |
| 2264 | assert (at == 0).all() and (bt == 0).all() |
| 2265 | results = dask.compute(*v) |
| 2266 | assert all([ev.size == 0 for ev in results]) |
| 2267 | assert (at == 2).all() and (bt == 3).all() |
| 2268 | |
| 2269 | at = np.zeros(shape=(4, 4)) |
| 2270 | bt = np.zeros(shape=(4, 4)) |
| 2271 | dat, dbt = store([a, b], [at, bt], compute=False, return_stored=True) |
| 2272 | assert isinstance(dat, Array) and isinstance(dbt, Array) |
| 2273 | assert (at == 0).all() and (bt == 0).all() |
| 2274 | assert (dat.compute() == at).all() and (dbt.compute() == bt).all() |
| 2275 | assert (at == 2).all() and (bt == 3).all() |
| 2276 | |
| 2277 | at = np.zeros(shape=(4, 4)) |
| 2278 | bt = np.zeros(shape=(4, 4)) |
| 2279 | dat, dbt = store( |
| 2280 | [a, b], [at, bt], compute=False, return_stored=True, load_stored=False |
| 2281 | ) |
| 2282 | assert isinstance(dat, Array) and isinstance(dbt, Array) |
| 2283 | assert (at == 0).all() and (bt == 0).all() |
| 2284 | dask.compute(dat, dbt) |
| 2285 | assert (at == 2).all() and (bt == 3).all() |
| 2286 | |
| 2287 | |
| 2288 | def test_store_nocompute_regions(): |