Skip to content

Commit

Permalink
Removed MapOperation class
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed May 8, 2017
1 parent 1b63552 commit c3d03cf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 45 deletions.
2 changes: 1 addition & 1 deletion holoviews/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
GridSpace, GridMatrix)

from .interface import * # noqa (API import)
from .operation import ElementOperation, MapOperation, TreeOperation # noqa (API import)
from .operation import ElementOperation, TreeOperation # noqa (API import)
from .element import * # noqa (API import)
from .element import __all__ as elements_list
from . import util # noqa (API import)
Expand Down
30 changes: 0 additions & 30 deletions holoviews/core/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,36 +185,6 @@ def __init__(self, callable, **kwargs):
super(OperationCallable, self).__init__(callable, **kwargs)


class MapOperation(param.ParameterizedFunction):
"""
A MapOperation takes a HoloMap containing elements or overlays and
processes them at the HoloMap level, returning arbitrary new
HoloMap objects as output. Unlike ElementOperation, MapOperations
can compute over all the keys and dimensions of the input map.
"""

group = param.String(default='MapOperation', doc="""
The group string to identify the output of the MapOperation.
By default this will match the MapOperation name.""")

def __call__(self, vmap, **params):
self.p = param.ParamOverrides(self, params)

if not isinstance(vmap, HoloMap):
raise Exception('MapOperation can only process Maps.')

return self._process(vmap)


def _process(self, view):
"""
Process a single input HoloMap, returning a new HoloMap
instance.
"""
raise NotImplementedError



class TreeOperation(Operation):
"""
A TreeOperation is the most general Operation type; it accepts any
Expand Down
20 changes: 8 additions & 12 deletions holoviews/core/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ def collapse(self, dimensions=None, function=None, spreadfn=None, **kwargs):
on the HoloMap. Homogenous Elements may be collapsed by
supplying a function, inhomogenous elements are merged.
"""
from .operation import MapOperation
if not dimensions:
dimensions = self.kdims
if not isinstance(dimensions, list): dimensions = [dimensions]
Expand All @@ -273,18 +272,15 @@ def collapse(self, dimensions=None, function=None, spreadfn=None, **kwargs):

collapsed = groups.clone(shared_data=False)
for key, group in groups.items():
if isinstance(function, MapOperation):
collapsed[key] = function(group, **kwargs)
else:
group_data = [el.data for el in group]
args = (group_data, function, group.last.kdims)
if hasattr(group.last, 'interface'):
col_data = group.type(group.table().aggregate(group.last.kdims, function, spreadfn, **kwargs))
group_data = [el.data for el in group]
args = (group_data, function, group.last.kdims)
if hasattr(group.last, 'interface'):
col_data = group.type(group.table().aggregate(group.last.kdims, function, spreadfn, **kwargs))

else:
data = group.type.collapse_data(*args, **kwargs)
col_data = group.last.clone(data)
collapsed[key] = col_data
else:
data = group.type.collapse_data(*args, **kwargs)
col_data = group.last.clone(data)
collapsed[key] = col_data
return collapsed if self.ndims > 1 else collapsed.last


Expand Down
4 changes: 2 additions & 2 deletions holoviews/operation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from ..core.operation import ElementOperation, MapOperation, TreeOperation # noqa (API import)
from ..core.operation import ElementOperation, TreeOperation # noqa (API import)
from ..core.options import Compositor

from .element import * # noqa (API import)
from ..core import Overlay # noqa (API import)

def public(obj):
if not isinstance(obj, type): return False
baseclasses = [ElementOperation, MapOperation, TreeOperation]
baseclasses = [ElementOperation, TreeOperation]
return any([issubclass(obj, bc) for bc in baseclasses])


Expand Down

0 comments on commit c3d03cf

Please sign in to comment.