Example #1
0
class DpxRamp(Widget):
    "Interface to filters needed for cleaning"
    __css__ = route("ramp.css")
    __javascript__ = route()
    __implementation__ = "_widget.ts"
    frozen = props.Bool(True)
    minhfsigma = props.Float(RampStatsTask.hfsigma[0])
    maxhfsigma = props.Float(RampStatsTask.hfsigma[1])
    minextension = props.Float(RampStatsTask.extension[0])
    fixedextension = props.Float(RampStatsTask.extension[1])
    maxextension = props.Float(RampStatsTask.extension[2])
    displaytype = props.Int(0)
Example #2
0
class Icon(AbstractIcon):
    """The Icon can be used to add SVG based icons to buttons, menus etc."""

    label = properties.String()
    text = properties.String(
        default="", help="""The text or HTML contents of the widget.""")
    size = properties.Float()
    fill_color = properties.String()
    spin_duration = properties.Int()
Example #3
0
class PeaksSequenceHover(  # pylint: disable=too-many-instance-attributes,too-many-ancestors
        HoverTool,
        SequenceHoverMixin
):
    "tooltip over peaks"
    maxcount  = props.Int(3)
    framerate = props.Float(1.)
    bias      = props.Float(0.)
    stretch   = props.Float(0.)
    updating  = props.String('')
    biases    = props.Dict(props.String, props.Float)
    stretches = props.Dict(props.String, props.Float)
    __implementation__ = SequenceHoverMixin.impl(
        'PeaksSequenceHover',
        {
            'stretches': ('[p.Any, {}]', 'any'),
            'biases':    ('[p.Any, {}]', 'any')
        },
        __file__
    )

    @classmethod
    def create(cls, ctrl, doc, fig, mdl, xrng = None):  # pylint: disable=too-many-arguments
        "Creates the hover tool for histograms"
        self = super().create(ctrl, doc, fig, mdl, xrng = xrng)
        jsc = CustomJS(args = {'fig': fig, 'source': self.source},
                       code = 'cb_obj.apply_update(fig, source)')
        self.js_on_change("updating", jsc)
        return self

    def reset(self, resets, ctrl, mdl):  # pylint: disable=arguments-differ
        "Creates the hover tool for histograms"
        super().reset(resets, ctrl, mdl,
                      biases    = {i: j.bias    for i, j in mdl.distances.items()},
                      stretches = {i: j.stretch for i, j in mdl.distances.items()})

    def jsslaveaxes(self, fig, src):  # pylint: disable=arguments-differ
        "slaves a histogram's axes to its y-axis"
        rng = fig.y_range
        rng.callback = CustomJS(code = "hvr.on_change_bounds(fig, src)",
                                args = dict(fig = fig, src = src, hvr = self))
        rng = fig.extra_y_ranges["bases"]
        rng.callback = CustomJS(code = "hvr.on_change_bases(fig)",
                                args = dict(fig = fig, hvr = self))
Example #4
0
class DpxCleaning(Widget):
    "Interface to filters needed for cleaning"
    __css__ = route("cleaning.css")
    __javascript__ = route()
    __implementation__ = "_widget.ts"
    frozen = props.Bool(True)
    framerate = props.Float(30.)
    figure = props.Instance(Figure)
    fixedbeads = props.String("")
    subtracted = props.String("")
    subtractcurrent = props.Int(0)

    maxabsvalue = props.Float(getattr(DataCleaningTask, 'maxabsvalue'))
    maxderivate = props.Float(getattr(DataCleaningTask, 'maxderivate'))
    minpopulation = props.Float(getattr(DataCleaningTask, 'minpopulation'))
    minhfsigma = props.Float(getattr(DataCleaningTask, 'minhfsigma'))
    maxhfsigma = props.Float(getattr(DataCleaningTask, 'maxhfsigma'))
    minextent = props.Float(getattr(DataCleaningTask, 'minextent'))
    maxextent = props.Float(getattr(DataCleaningTask, 'maxextent'))
    maxsaturation = props.Float(getattr(DataCleaningTask, 'maxsaturation'))
Example #5
0
    lambda p, kwargs: (bp.ColumnData(bp.Any, bp.Seq(bp.Any), **kwargs), [(
        bp.PandasDataFrame, lambda x: ColumnDataSource._data_from_df(x))]),
    pm.DateRange:
    lambda p, kwargs: bp.Tuple(bp.Datetime, bp.Datetime, **kwargs),
    pm.Date:
    lambda p, kwargs: bp.Datetime(**kwargs),
    pm.Dict:
    lambda p, kwargs: bp.Dict(bp.String, bp.Any, **kwargs),
    pm.Event:
    lambda p, kwargs: bp.Bool(**kwargs),
    pm.Integer:
    lambda p, kwargs: bp.Int(**kwargs),
    pm.List:
    lambda p, kwargs: bp.List(bp.Any, **kwargs),
    pm.Number:
    lambda p, kwargs: bp.Float(**kwargs),
    pm.NumericTuple:
    lambda p, kwargs: bp.Tuple(*(bp.Float for p in p.length), **kwargs),
    pm.Range:
    lambda p, kwargs: bp.Tuple(bp.Float, bp.Float, **kwargs),
    pm.String:
    lambda p, kwargs: bp.String(**kwargs),
    pm.Tuple:
    lambda p, kwargs: bp.Tuple(*(bp.Any for p in p.length), **kwargs),
}


def construct_data_model(parameterized, name=None, ignore=[], types={}):
    """
    Dynamically creates a Bokeh DataModel class from a Parameterized
    object.
Example #6
0
class DpxHoverModel(
        HoverTool,  # pylint: disable=too-many-instance-attributes,too-many-ancestors
        SequenceHoverMixin):
    "controls keypress actions"
    maxcount = props.Int(3)
    framerate = props.Float(1.)
    shape = props.Tuple(props.Int, props.Int, default=(0, 0))
    cycle = props.Int(-1)
    bias = props.Float(0.)
    stretch = props.Float(0.)
    updating = props.String('')
    rawrend = props.Instance(Renderer)
    impl = SequenceHoverMixin.impl
    __implementation__ = impl(
        'DpxHoverModel', {
            '_hvr_cnt': ('[p.Number, -1]', 'number'),
            'shape': ('[p.Array, [2,1]]', 'number[]'),
            'cycle': ('[p.Int, -1]', 'number'),
            'rawrend': ('[p.Instance, null]', 'any')
        }, __file__)

    @staticmethod
    def _createrawdata(data, shape):
        return dict(t=data['t'][:shape[1]], z=data['z'][:shape[1]])

    @staticmethod
    def __settooltips(fig, theme):
        tooltips = theme.tooltips
        hover = fig.select(DpxHoverTool)

        if tooltips is None or len(tooltips) == 0:
            if len(hover):
                hover[0].tooltips = None

        elif len(hover):
            name = theme.raw.glyph
            rend = [
                i for i in fig.renderers if hasattr(i, 'glyph')
                and type(i.glyph).__name__.lower() == name
            ][0]
            hover[0].tooltips = tooltips
            hover[0].renderers = [rend]
            rend.selection_glyph = None
            rend.nonselection_glyph = None
            rend.glyph.radius_dimension = 'x'
            rend.glyph.radius = theme.radius

    def __settap(self, mdl, fig, source, theme):
        tap = fig.select(TapTool)
        if tap is not None and len(tap):
            src = ColumnDataSource(self._createrawdata(source.data,
                                                       self.shape))
            sel = themed(mdl, theme.selection)
            glyph = PlotAttrsView(sel).addto(fig, x='t', y='z', source=src)
            args = dict(hvr=self, hvrsrc=src, rawsrc=source, glyph=glyph)
            code = "hvr.launch_hover(rawsrc, hvrsrc, glyph)"
            self.rawrend = glyph
            source.callback = CustomJS(code=code, args=args)

    def createraw(self, mdl, fig, source, shape, theme):  # pylint: disable=too-many-arguments
        "creates the hover tool"
        self.shape = tuple(shape)
        self.__settooltips(fig, theme)
        self.__settap(mdl, fig, source, theme)

    def slaveaxes(self, fig, src):
        "slaves a histogram's axes to its y-axis"
        fig.y_range.callback = CustomJS(
            code="hvr.on_change_hist_bounds(fig, src)",
            args=dict(hvr=self, fig=fig, src=src))

    def resetraw(self, fig, rdata, shape, resets):
        "updates the tooltips for a new file"
        hover = fig.select(DpxHoverTool)
        if len(hover) == 0:
            return

        resets[self]['shape'] = shape
        if self.rawrend is not None:
            resets[self.rawrend]['visible'] = False
            resets[self.rawrend.data_source]['data'] = self._createrawdata(
                rdata, shape)