Skip to content

Commit

Permalink
Raise non-gridded data errors on raster types (#2304)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored and jlstevens committed Feb 6, 2018
1 parent 25b785f commit 9e04789
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions holoviews/element/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

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
Expand Down Expand Up @@ -243,6 +244,11 @@ def __init__(self, data, kdims=None, vdims=None, bounds=None, extents=None,
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:
Expand Down Expand Up @@ -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')],
Expand All @@ -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.
Expand Down

0 comments on commit 9e04789

Please sign in to comment.