def test_distribution_composite_not_filled(self):
     dist = Distribution(np.array([0, 1,
                                   2]), ).opts(plot=dict(filled=False))
     curve = Compositor.collapse_element(dist, backend='matplotlib')
     self.assertIsInstance(curve, Curve)
     self.assertEqual(curve.vdims,
                      [Dimension(('Value_density', 'Value Density'))])
Beispiel #2
0
 def test_bivariate_composite_filled(self):
     dist = Bivariate(np.random.rand(10, 2)).opts(plot=dict(filled=True))
     contours = Compositor.collapse_element(dist)
     self.assertIsInstance(contours, Polygons)
     self.assertEqual(contours.vdims, [Dimension('Density')])
Beispiel #3
0
 def test_bivariate_composite_transfer_opts_with_group(self):
     dist = Bivariate(np.random.rand(10, 2), group='Test').opts(style=dict(cmap='Blues'))
     contours = Compositor.collapse_element(dist)
     opts = Store.lookup_options('matplotlib', contours, 'style').kwargs
     self.assertEqual(opts.get('cmap', None), 'Blues')
Beispiel #4
0
 def test_distribution_composite_transfer_opts_with_group(self):
     dist = Distribution(np.array([0, 1, 2]), group='Test').opts(style=dict(color='red'))
     area = Compositor.collapse_element(dist, backend='matplotlib')
     opts = Store.lookup_options('matplotlib', area, 'style').kwargs
     self.assertEqual(opts.get('color', None), 'red')
Beispiel #5
0
        return results

from holoviews.core.options import Compositor
from .analysis import toHCS

#Default styles
options = Store.options(backend='matplotlib')
options.Image.Preference = Options('style', cmap='hsv')
options.Image.Selectivity = Options('style', cmap='gray')
options.Image.Activity = Options('style', cmap='gray')
options.Image.Response = Options('style', cmap='gray')
options.Image.FFT_Power = Options('style', cmap='gray')

# Default channel definitions
Compositor.register(
    Compositor('Image.Orientation_Preference * Image.Orientation_Selectivity',
               toHCS, 'OR PrefSel', mode='display', flipSC=True))

Compositor.register(
    Compositor('Image.Direction_Preference * Image.Direction_Selectivity',
               toHCS, 'DR PrefSel', mode='display', flipSC=True))

Compositor.register(
    Compositor('Image.Orientation_Preference * Image.Activity',
               toHCS, 'ORColoredResponse', mode='display', flipSC=True))


__all__ = [
    "DistributionMatrix",
    "FullMatrix",
    "FeatureResponses",
Beispiel #6
0
    FeatureMaps, ReverseCorrelation, MeasureResponseCommand, pattern_response,\
    topo_metadata_fn, StorageHook, get_feature_preference
from topo.base.projection import Projection
from topo.base.sheet import Sheet
from topo.base.sheetview import CFView
from topo.misc.ipython import RunProgress
from topo.misc import color

from command import measure_cog



CoG_spec = "Image.X CoG * Image.Y CoG * Image.BlueChannel"
XYCoG = chain.instance(group='XYCoG', name='XYCoG',
                       operations = [image_overlay.instance(spec=CoG_spec), factory.instance()])
Compositor.register(Compositor("Image.X CoG * Image.Y CoG", XYCoG, 'XYCoG', 'display'))


import param
from holoviews import RGB, ElementOperation
from holoviews.operation.normalization import raster_normalization


class colorizeHSV(ElementOperation):
    """
    Given an Overlay consisting of two Image elements, colorize the
    data in the bottom Image with the data in the top Image using
    the HSV color space.
    """

    group = param.String(default='ColorizedHSV', doc="""
Beispiel #7
0
from holoviews.operation import gridmatrix

from .operation import regression
from holoviews.plotting.bokeh import CurvePlot


#unsure if necessary?
class Regression(hv.Curve):

    group = param.String(default='Regression')


class RegressionPlot(CurvePlot):
    """
    RegressionPlot visualizes a distribution of values as a trend in time.
    """


Compositor.register(
    Compositor("Regression",
               regression,
               None,
               'data',
               transfer_options=True,
               transfer_parameters=True,
               output_type=hv.Curve,
               backends=['bokeh', 'matplotlib']))

hv.Store.register({Regression: RegressionPlot}, 'bokeh')
hv.Store.set_current_backend('bokeh')
 def test_bivariate_composite_empty_not_filled(self):
     dist = Bivariate([]).opts(plot=dict(filled=True))
     contours = Compositor.collapse_element(dist, backend='matplotlib')
     self.assertIsInstance(contours, Contours)
     self.assertEqual(contours.vdims, [Dimension('Density')])
     self.assertEqual(len(contours), 0)
Beispiel #9
0
 def test_bivariate_composite(self):
     dist = Bivariate(np.random.rand(10, 2))
     contours = Compositor.collapse_element(dist, backend='matplotlib')
     self.assertIsInstance(contours, Contours)
     self.assertEqual(contours.vdims, [Dimension('Density')])
Beispiel #10
0
 def test_bivariate_composite_filled(self):
     dist = Bivariate(np.random.rand(10, 2)).opts(plot=dict(filled=True))
     contours = Compositor.collapse_element(dist)
     self.assertIsInstance(contours, Polygons)
     self.assertEqual(contours.vdims, [Dimension('Density')])
Beispiel #11
0
 def test_bivariate_composite(self):
     dist = Bivariate(np.random.rand(10, 2))
     contours = Compositor.collapse_element(dist)
     self.assertIsInstance(contours, Contours)
     self.assertEqual(contours.vdims, [Dimension('Density')])
Beispiel #12
0
 def test_distribution_composite_not_filled(self):
     dist = Distribution(np.array([0, 1, 2])).opts(plot=dict(filled=False))
     curve = Compositor.collapse_element(dist)
     self.assertIsInstance(curve, Curve)
     self.assertEqual(curve.vdims, [Dimension(('Value_density', 'Value Density'))])
Beispiel #13
0
    FeatureMaps, ReverseCorrelation, MeasureResponseCommand, pattern_response,\
    topo_metadata_fn, StorageHook, get_feature_preference
from topo.base.projection import Projection
from topo.base.sheet import Sheet
from topo.base.sheetview import CFView
from topo.misc.ipython import RunProgress
from topo.misc import color

from command import measure_cog



CoG_spec = "Image.X CoG * Image.Y CoG * Image.BlueChannel"
XYCoG = chain.instance(group='XYCoG', name='XYCoG',
                       operations = [image_overlay.instance(spec=CoG_spec), factory.instance()])
Compositor.register(Compositor("Image.X CoG * Image.Y CoG", XYCoG, 'XYCoG', 'display'))


import param
from holoviews import RGB, Image, ElementOperation
from holoviews.operation.normalization import raster_normalization


class colorizeHSV(ElementOperation):
    """
    Given an Overlay consisting of two Image elements, colorize the
    data in the bottom Image with the data in the top Image using
    the HSV color space.
    """

    group = param.String(default='ColorizedHSV', doc="""
Beispiel #14
0
        _load_mpl()
else:
    try:
        from . import mpl  # noqa
    except ImportError:
        pass

    try:
        from . import bokeh  # noqa
    except ImportError:
        pass

Compositor.register(
    Compositor("LineContours",
               contours,
               None,
               'data',
               transfer_options=True,
               transfer_parameters=True,
               output_type=Contours,
               backends=['bokeh', 'matplotlib']))
Compositor.register(
    Compositor("FilledContours",
               contours.instance(filled=True),
               None,
               'data',
               transfer_options=True,
               transfer_parameters=True,
               output_type=Polygons,
               backends=['bokeh', 'matplotlib']))
Beispiel #15
0
    def _load_mpl():
        from . import mpl # noqa
    extension.register_backend_callback('matplotlib', _load_mpl)

    backends = Store.loaded_backends()
    if 'bokeh' in backends:
        _load_bokeh()
    if 'matplotlib' in backends:
        _load_mpl()
else:
    try:
        from . import mpl # noqa
    except ImportError:
        pass

    try:
        from . import bokeh # noqa
    except ImportError:
        pass

Compositor.register(Compositor("LineContours", contours, None,
                               'data', transfer_options=True,
                               transfer_parameters=True,
                               output_type=Contours,
                               backends=['bokeh', 'matplotlib']))
Compositor.register(Compositor("FilledContours", contours.instance(filled=True),
                               None, 'data', transfer_options=True,
                               transfer_parameters=True,
                               output_type=Polygons,
                               backends=['bokeh', 'matplotlib']))
 def test_bivariate_composite_filled(self):
     dist = Bivariate(np.random.rand(10, 2)).opts(plot=dict(filled=True))
     contours = Compositor.collapse_element(dist, backend='matplotlib')
     self.assertIsInstance(contours, Polygons)
     self.assertEqual(contours.vdims[0].name, 'Density')
Beispiel #17
0
 def test_bivariate_composite_filled(self):
     dist = Bivariate(np.random.rand(10, 2)).opts(plot=dict(filled=True))
     contours = Compositor.collapse_element(dist, backend='matplotlib')
     self.assertIsInstance(contours, Polygons)
     self.assertEqual(contours.vdims[0].name, 'Density')
Beispiel #18
0
    """
    Applies hex binning by computing aggregates on a hexagonal grid.

    Should not be user facing as the returned element is not directly
    useable.
    """
    def _process(self, element, key=None):
        if isinstance(element, HexTiles):
            element = project_points._process(self, element)
        return hex_binning._process(self, element)


compositor = Compositor("HexTiles",
                        geo_hex_binning,
                        None,
                        'data',
                        output_type=HexTiles,
                        transfer_options=True,
                        transfer_parameters=True,
                        backends=['bokeh'])
Compositor.register(compositor)

Store.register(
    {
        WMTS: TilePlot,
        Points: GeoPointPlot,
        Labels: GeoLabelsPlot,
        VectorField: GeoVectorFieldPlot,
        Polygons: GeoPolygonPlot,
        Contours: GeoContourPlot,
        Rectangles: GeoRectanglesPlot,
        Segments: GeoSegmentsPlot,
 def test_distribution_composite_empty_not_filled(self):
     dist = Distribution([]).opts(plot=dict(filled=False))
     curve = Compositor.collapse_element(dist)
     self.assertIsInstance(curve, Curve)
     self.assertEqual(curve.vdims,
                      [Dimension(('Value_density', 'Value Density'))])
Beispiel #20
0
    topo_metadata_fn, StorageHook, get_feature_preference
from topo.base.projection import Projection
from topo.base.sheet import Sheet
from topo.base.sheetview import CFView
from topo.misc.ipython import RunProgress
from topo.misc import color

from command import measure_cog

CoG_spec = "Image.X CoG * Image.Y CoG * Image.BlueChannel"
XYCoG = chain.instance(
    group='XYCoG',
    name='XYCoG',
    operations=[image_overlay.instance(spec=CoG_spec),
                factory.instance()])
Compositor.register(
    Compositor("Image.X CoG * Image.Y CoG", XYCoG, 'XYCoG', 'display'))

import param
from holoviews import RGB, ElementOperation
from holoviews.operation.normalization import raster_normalization


class colorizeHSV(ElementOperation):
    """
    Given an Overlay consisting of two Image elements, colorize the
    data in the bottom Image with the data in the top Image using
    the HSV color space.
    """

    group = param.String(default='ColorizedHSV',
                         doc="""
 def test_distribution_composite(self):
     dist = Distribution(np.array([0, 1, 2]))
     area = Compositor.collapse_element(dist, backend='matplotlib')
     self.assertIsInstance(area, Area)
     self.assertEqual(area.vdims, [Dimension(('Value_density', 'Density'))])
 def test_distribution_composite_transfer_opts_with_group(self):
     dist = Distribution(np.array([0, 1, 2]), group='Test').opts(style=dict(color='red'))
     area = Compositor.collapse_element(dist, backend='matplotlib')
     opts = Store.lookup_options('matplotlib', area, 'style').kwargs
     self.assertEqual(opts.get('color', None), 'red')
 def test_distribution_composite_custom_vdim(self):
     dist = Distribution(np.array([0, 1, 2]), vdims=['Test'])
     area = Compositor.collapse_element(dist, backend='matplotlib')
     self.assertIsInstance(area, Area)
     self.assertEqual(area.vdims, [Dimension('Test')])
Beispiel #24
0
 def test_distribution_composite(self):
     dist = Distribution(np.array([0, 1, 2]))
     area = Compositor.collapse_element(dist, backend='matplotlib')
     self.assertIsInstance(area, Area)
     self.assertEqual(area.vdims, [Dimension(('Value_density', 'Value Density'))])
 def test_distribution_composite_empty_not_filled(self):
     dist = Distribution([]).opts(plot=dict(filled=False))
     curve = Compositor.collapse_element(dist, backend='matplotlib')
     self.assertIsInstance(curve, Curve)
     self.assertEqual(curve.vdims, [Dimension(('Value_density', 'Density'))])
Beispiel #26
0
 def test_distribution_composite_custom_vdim(self):
     dist = Distribution(np.array([0, 1, 2]), vdims=['Test'])
     area = Compositor.collapse_element(dist, backend='matplotlib')
     self.assertIsInstance(area, Area)
     self.assertEqual(area.vdims, [Dimension('Test')])
 def test_bivariate_composite_transfer_opts_with_group(self):
     dist = Bivariate(np.random.rand(10, 2), group='Test').opts(style=dict(cmap='Blues'))
     contours = Compositor.collapse_element(dist, backend='matplotlib')
     opts = Store.lookup_options('matplotlib', contours, 'style').kwargs
     self.assertEqual(opts.get('cmap', None), 'Blues')
Beispiel #28
0
 def test_bivariate_composite_custom_vdim(self):
     dist = Bivariate(np.random.rand(10, 2), vdims=['Test'])
     contours = Compositor.collapse_element(dist)
     self.assertIsInstance(contours, Contours)
     self.assertEqual(contours.vdims, [Dimension('Test')])
 def test_bivariate_composite_custom_vdim(self):
     dist = Bivariate(np.random.rand(10, 2), vdims=['Test'])
     contours = Compositor.collapse_element(dist, backend='matplotlib')
     self.assertIsInstance(contours, Contours)
     self.assertEqual(contours.vdims, [Dimension('Test')])
Beispiel #30
0
 def test_bivariate_composite_empty_not_filled(self):
     dist = Bivariate([]).opts(plot=dict(filled=True))
     contours = Compositor.collapse_element(dist)
     self.assertIsInstance(contours, Contours)
     self.assertEqual(contours.vdims, [Dimension('Density')])
     self.assertEqual(len(contours), 0)
Beispiel #31
0
    Applies hex binning by computing aggregates on a hexagonal grid.

    Should not be user facing as the returned element is not directly
    useable.
    """

    def _process(self, element, key=None):
        if isinstance(element, HexTiles):
            element = project_points._process(self, element)
        return hex_binning._process(self, element)

compositor = Compositor(
    "HexTiles", geo_hex_binning, None, 'data', output_type=HexTiles,
    transfer_options=True, transfer_parameters=True, backends=['bokeh']
)
Compositor.register(compositor)


Store.register({WMTS: TilePlot,
                Points: GeoPointPlot,
                Labels: GeoLabelsPlot,
                VectorField: GeoVectorFieldPlot,
                Polygons: GeoPolygonPlot,
                Contours: GeoContourPlot,
                Path: GeoPathPlot,
                Shape: GeoShapePlot,
                Image: GeoRasterPlot,
                RGB: GeoRGBPlot,
                LineContours: LineContourPlot,
                FilledContours: FilledContourPlot,
                Feature: FeaturePlot,