dask: `cf.size` by davidhassell · Pull Request #554 · NCAS-CMS/cf-python
Replace np.size(...) with the new cf.size(...), which is a basically a copy of the numpy function.
The reason for doing this is that when dask arrays are passed to np.size this happens:
>>> import numpy as np >>> import dask.array as da >>> np.size(da.arange(9)) /home/david/miniconda3/lib/python3.9/site-packages/dask/array/core.py:1712: FutureWarning: The `numpy.size` function is not implemented by Dask array. You may want to use the da.map_blocks function or something similar to silence this warning. Your code may stop working in a future release. warnings.warn( 9 >>>
This is related to how Dask interacts with the numpy __array_function__ interface: https://github.com/dask/dask/blob/2022.12.1/dask/array/core.py#L1707-L1728. I haven't really looked at what is going on here, but what look I had led me to think that creating our own little function was the path of least resistance :). If this were to be something which could be "fixed" via Dask functionality, then great! But until such a time we are covered.
Took the liberty of deleting some ancient redundant code from field.py at the same time.