Skip to content

Commit dcd47cb

Browse files
refactored DatalessError (#6865)
Co-authored-by: Chris Bunney <[email protected]>
1 parent 2586e00 commit dcd47cb

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

lib/iris/_lazy_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def _co_realise_lazy_arrays(arrays):
370370
if real_out is not None:
371371
real_out = np.asanyarray(real_out)
372372
else:
373-
raise iris.exceptions.DatalessError("realising")
373+
raise iris.exceptions.DatalessError("Data is None; cannot be realised.")
374374
if isinstance(real_out, ma.core.MaskedConstant):
375375
# Convert any masked constants into NumPy masked arrays.
376376
# NOTE: in this case, also apply the original lazy-array dtype, as

lib/iris/cube.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5374,7 +5374,9 @@ def interpolate(
53745374
53755375
"""
53765376
if self.is_dataless():
5377-
raise iris.exceptions.DatalessError("interpolate")
5377+
raise iris.exceptions.DatalessError(
5378+
"Dataless cubes cannot be interpolated."
5379+
)
53785380
coords, points = zip(*sample_points)
53795381
interp = scheme.interpolator(self, coords) # type: ignore[arg-type]
53805382
return interp(points, collapse_scalar=collapse_scalar)
@@ -5421,7 +5423,7 @@ def regrid(self, grid: Cube, scheme: iris.analysis.RegriddingScheme) -> Cube:
54215423
54225424
"""
54235425
if self.is_dataless():
5424-
raise iris.exceptions.DatalessError("regrid")
5426+
raise iris.exceptions.DatalessError("Dataless cubes cannot be regridded.")
54255427
regridder = scheme.regridder(self, grid)
54265428
return regridder(self)
54275429

lib/iris/exceptions.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,9 @@ class CannotAddError(ValueError):
170170

171171

172172
class DatalessError(ValueError):
173-
"""Raised when an method cannot be performed on a dataless :class:`~iris.cube.Cube`."""
173+
"""Raised when a method cannot be performed on a dataless :class:`~iris.cube.Cube`."""
174174

175-
def __str__(self):
176-
msg = (
177-
"Dataless cubes are still early in implementation, and dataless {} "
178-
"operations are not currently supported."
179-
)
180-
return msg.format(super().__str__())
175+
pass
181176

182177

183178
class CFParseError(IrisError):

0 commit comments

Comments
 (0)