MCPcopy Create free account
hub / github.com/dask/dask / test_array_vs_dataframe

Function test_array_vs_dataframe

dask/tests/test_order.py:1395–1428  ·  view source on GitHub ↗
(optimize)

Source from the content-addressed store, hash-verified

1393 ],
1394)
1395def test_array_vs_dataframe(optimize):
1396 xr = pytest.importorskip("xarray")
1397 pytest.importorskip("dask.dataframe")
1398
1399 import dask.array as da
1400
1401 size = 5000
1402 ds = xr.Dataset(
1403 dict(
1404 anom_u=(
1405 ["time", "face", "j", "i"],
1406 da.random.random((size, 1, 987, 1920), chunks=(10, 1, -1, -1)),
1407 ),
1408 anom_v=(
1409 ["time", "face", "j", "i"],
1410 da.random.random((size, 1, 987, 1920), chunks=(10, 1, -1, -1)),
1411 ),
1412 )
1413 )
1414
1415 quad = ds**2
1416 quad["uv"] = ds.anom_u * ds.anom_v
1417 mean = quad.mean("time")
1418 diag_array = diagnostics(
1419 collections_to_expr([mean], optimize_graph=optimize).optimize().__dask_graph__()
1420 )
1421 diag_df = diagnostics(
1422 collections_to_expr([mean.to_dask_dataframe()], optimize_graph=optimize)
1423 .optimize()
1424 .__dask_graph__()
1425 )
1426 assert max(diag_df[1]) == 15
1427 assert max(diag_array[1]) == 38
1428 assert max(diag_array[1]) < 50
1429
1430
1431def test_anom_mean():

Callers

nothing calls this directly

Calls 8

diagnosticsFunction · 0.90
collections_to_exprFunction · 0.90
maxFunction · 0.85
to_dask_dataframeMethod · 0.80
randomMethod · 0.45
meanMethod · 0.45
__dask_graph__Method · 0.45
optimizeMethod · 0.45

Tested by

no test coverage detected