MCPcopy
hub / github.com/dask/dask / test_array_vs_dataframe

Function test_array_vs_dataframe

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

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…