Raise non-gridded data errors on raster types
@@ -7,6 +7,7 @@ import param
from ..core import util, config
from ..core.data import ImageInterface, GridInterface
+from ..core.data.interface import DataError
from ..core import Dimension, Element2D, Overlay, Dataset
from ..core.boundingregion import BoundingRegion, BoundingBox
from ..core.sheetcoords import SheetCoordinateSystem, Slice
@@ -243,6 +244,11 @@ class Image(Dataset, Raster, SheetCoordinateSystem):
or (isinstance(data, np.ndarray) and data.size == 0)):
data = np.zeros((2, 2))
Dataset.__init__(self, data, kdims=kdims, vdims=vdims, extents=extents, **params)
+ if not self.interface.gridded:
+ raise DataError("%s type expects gridded data, %s is columnar."
+ "To display columnar data as gridded use the HeatMap "
+ "element or aggregate the data." %
+ (type(self).__name__, self.interface.__name__))
dim2, dim1 = self.interface.shape(self, gridded=True)[:2]
if bounds is None:
@@ -637,8 +643,6 @@ class QuadMesh(Dataset, Element2D):
2D arrays for the x-/y-coordinates and grid values.
"""
- datatype = param.List(default=['grid', 'xarray'])
-
group = param.String(default="QuadMesh", constant=True)
kdims = param.List(default=[Dimension('x'), Dimension('y')],
@@ -648,6 +652,15 @@ class QuadMesh(Dataset, Element2D):
_binned = True
+ def __init__(self, data, kdims=None, vdims=None, **params):
+ super(QuadMesh, self).__init__(data, kdims, vdims, **params)
+ if not self.interface.gridded:
+ raise DataError("%s type expects gridded data, %s is columnar."
+ "To display columnar data as gridded use the HeatMap "
+ "element or aggregate the data." %
+ (type(self).__name__, self.interface.__name__))
+
+
def __setstate__(self, state):
"""
Ensures old-style QuadMesh types without an interface can be unpickled.
