cf.Data.cull_graph

Data.cull_graph(*args, **kwargs)[source]

Remove unnecessary tasks from the dask graph in-place.

Performance

An unnecessary task is one which does not contribute to the computed result. Such tasks are always automatically removed (culled) at compute time, but removing them beforehand might improve performance by reducing the amount of work done in later steps.

Added in version (cfdm): 1.11.2.0

Parameters:
inplace: bool, optional

If True then do the operation in-place and return None.

Added in version (cfdm): 1.12.0.0

Returns:

None

Examples

>>> d = cfdm.Data([1, 2, 3, 4, 5], chunks=3)
>>> d = d[:2]
>>> dict(d.to_dask_array().dask)
{('array-729a27a557981dd627b6c07e8ef93250', 0): array([1, 2, 3]),
 ('array-729a27a557981dd627b6c07e8ef93250', 1): array([4, 5]),
 ('getitem-9890f07ccf98df4ab5231fbd87792f74',
  0): <Task ('getitem-9890f07ccf98df4ab5231fbd87792f74', 0) getitem(...)>,
 ('cfdm_harden_mask-d28b364730f9d5b38cfbd835b29a403c',
  0): <Task ('cfdm_harden_mask-d28b364730f9d5b38cfbd835b29a403c', 0) cfdm_harden_mask(...)>}
>>> d.cull_graph()
{('getitem-9890f07ccf98df4ab5231fbd87792f74',
  0): <Task ('getitem-9890f07ccf98df4ab5231fbd87792f74', 0) getitem(...)>,
 ('array-729a27a557981dd627b6c07e8ef93250', 0): array([1, 2, 3]),
 ('cfdm_harden_mask-d28b364730f9d5b38cfbd835b29a403c',
  0): <Task ('cfdm_harden_mask-d28b364730f9d5b38cfbd835b29a403c', 0) cfdm_harden_mask(...)>}