-
Notifications
You must be signed in to change notification settings - Fork 300
Closed
Labels
Description
🐛 Bug Report
When constructing a coordinate's points, Iris checks whether the points are regularly spaced (see https://github.com/SciTools/iris/blob/main/lib/iris/util.py#L1458-L1464). If the coordinate has a single point, np.mean(diffs) is performed on an empty ndarray, and raises a numpy warning.
How To Reproduce
Steps to reproduce the behaviour:
from iris.coords import DimCoord
DimCoord.from_regular(zeroth=0, step=20, count=1)
(with numpy v1.19.2) Returns:
/path_to_env/lib/python3.6/site-packages/numpy/core/fromnumeric.py:3373: RuntimeWarning: Mean of empty slice.
out=out, **kwargs)
/path_to_env/lib/python3.6/site-packages/numpy/core/_methods.py:170: RuntimeWarning: invalid value encountered in true_divide
ret = ret.dtype.type(ret / rcount)
DimCoord(array([20.], dtype=float32), standard_name=None, units=Unit('unknown'))
Expected behaviour
Perhaps skip the check that the points are regularly spaced if the points are of length 1?
rcomerrcomer