How to use the param.Number function in param

To help you get started, we’ve selected a few param examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holoviz / param / tests / API0 / View on Github external
        assert t.dyn!=t.dyn
        orig = t.dyn
        assert t.inspect_value('dyn')!=orig
        assert t.inspect_value('dyn')==orig

from param import parameterized

class some_fn(param.ParameterizedFunction):
   num_phase = param.Number(18)
   frequencies = param.List([99])
   scale = param.Number(0.3)

   def __call__(self,**params_to_override):
       params = parameterized.ParamOverrides(self,params_to_override)
       num_phase = params['num_phase']
       frequencies = params['frequencies']
       scale = params['scale']
       return scale,num_phase,frequencies

instance = some_fn.instance()

class TestParameterizedFunction(unittest.TestCase):

    def _basic_tests(self,fn):
github holoviz / param / tests / API1 / View on Github external
def setUp(self):
        super(TestParamPager, self).setUp()
        self.maxDiff = None
        class TestClass(param.Parameterized):
            u = param.Number(4)
            v = param.Number(4, constant=True)
            w = param.Number(4, readonly=True)
            x = param.String(None, allow_None=True)
            y = param.Number(4, bounds=(-1, None))
            z = param.Number(4, bounds=(-1, 100), softbounds=(-100, -200))

        self.TestClass = TestClass
        self.pager = ParamPager()
github holoviz / panel / examples / apps / django2 / sliders / View on Github external
import param
import numpy as np

from bokeh.models import ColumnDataSource
from bokeh.plotting import figure

class SineWave(param.Parameterized):

    offset = param.Number(default=0.0, bounds=(-5.0,5.0))
    amplitude = param.Number(default=1.0, bounds=(-5.0,5.0))
    phase = param.Number(default=0.0,bounds=(0.0,2*np.pi))
    frequency = param.Number(default=1.0, bounds=(0.1, 5.1))
    N = param.Integer(default=200, bounds=(0,None))
    x_range = param.Range(default=(0, 4*np.pi),bounds=(0,4*np.pi))
    y_range = param.Range(default=(-2.5,2.5),bounds=(-10,10))

    def __init__(self, **params):
        x, y = self.sine()
        self.cds = ColumnDataSource(data=dict(x=x, y=y))
        self.plot = figure(plot_height=400, plot_width=400,
                           x_range=self.x_range, y_range=self.y_range)
        self.plot.line('x', 'y', source=self.cds, line_width=3, line_alpha=0.6)

    @param.depends('N', 'frequency', 'amplitude', 'offset', 'phase', 'x_range', 'y_range', watch=True)
    def update_plot(self):
github holoviz / param / numbergen / View on Github external
Concentration (inverse variance).""")

    def __call__(self):
        super(VonMisesRandom, self).__call__()
        return self.random_generator.vonmisesvariate(,self.kappa)

class ScaledTime(NumberGenerator, TimeDependent):
    The current time multiplied by some conversion factor.

    factor = param.Number(default=1.0, doc="""
       The factor to be multiplied by the current time value.""")

    def __call__(self):
        return float(self.time_fn() * self.factor)

class BoxCar(NumberGenerator, TimeDependent):
    The boxcar function over the specified time interval. The bounds
    are exclusive: zero is returned at the onset time and at the
    offset (onset+duration).

    If duration is None, then this reduces to a step function around the
    onset value with no offset.
github holoviz / holoviews / holoviews / plotting / bokeh / View on Github external
from ...core.util import (
    OrderedDict, max_range, basestring, dimension_sanitizer,
    isfinite, range_pad, dimension_range)
from ...element import Bars
from ...operation import interpolate_curve
from ...util.transform import dim
from ..util import compute_sizes, get_min_distance, get_axis_padding
from .element import ElementPlot, ColorbarPlot, LegendPlot
from .styles import (expand_batched_style, line_properties, fill_properties,
                     mpl_to_bokeh, rgb2hex)
from .util import bokeh_version, categorize_array

class PointPlot(LegendPlot, ColorbarPlot):

    jitter = param.Number(default=None, bounds=(0, None), doc="""
      The amount of jitter to apply to offset the points along the x-axis.""")

    # Deprecated parameters

    color_index = param.ClassSelector(default=None, class_=(basestring, int),
                                      allow_None=True, doc="""
        Deprecated in favor of color style mapping, e.g. `color=dim('color')`""")

    size_index = param.ClassSelector(default=None, class_=(basestring, int),
                                     allow_None=True, doc="""
        Deprecated in favor of size style mapping, e.g. `size=dim('size')`""")

    scaling_method = param.ObjectSelector(default="area",
                                          objects=["width", "area"],
        Deprecated in favor of size style mapping, e.g.
github holoviz / holoviews / holoviews / plotting / mpl / View on Github external
def get_data(self, element, ranges, style):
        style.pop('zorder', None)
        if self.invert_axes:
            style['vertical'] = True
        vdim = element.vdims[0]
        axis_kwargs = dict(dimensions=[vdim])
        return (element.dimension_values(vdim),), style, axis_kwargs

    def init_artists(self, ax, plot_data, plot_kwargs):
        return {'axis': sns.distplot(*plot_data, ax=ax, **plot_kwargs)}

class SideDistributionPlot(AdjoinedPlot, DistributionPlot):

    border_size = param.Number(default=0.2, doc="""
        The size of the border expressed as a fraction of the main plot.""")

class SNSFramePlot(DFrameViewPlot):
    SNSFramePlot takes an SNSFrame as input and plots the
    contained data using the set plot_type. This largely mirrors
    the way DFramePlot works, however, since most Seaborn plot
    types plot one dimension against another it uses the x and y
    parameters, which can be set on the SNSFrame.

    plot_type = param.ObjectSelector(default='scatter_matrix',
                                     objects=['interact', 'regplot',
                                              'lmplot', 'corrplot',
                                              'plot', 'boxplot',
github pyviz-topics / imagen / imagen / View on Github external

### JABALERT: This class should be eliminated if at all possible; it
### is just a specialized version of Composite, and should be
### implementable directly using what is already in Composite.
class GaussiansCorner(PatternGenerator):
    Two Gaussian pattern generators with a variable intersection point,
    appearing as a corner or cross.

    x = param.Number(default=-0.15,bounds=(-1.0,1.0),softbounds=(-0.5,0.5),
                doc="X center of the corner")

    y = param.Number(default=-0.15,bounds=(-1.0,1.0),softbounds=(-0.5,0.5),
                doc="Y center of the corner")

    size = param.Number(default=0.5,bounds=(0,None), softbounds=(0.1,1),
                doc="The size of the corner")

    aspect_ratio = param.Number(default=1/0.31, bounds=(0,None), softbounds=(1,10),
                doc="Ratio of the width to the height for both Gaussians")

    angle = param.Number(default=0.5*pi,bounds=(0,pi), softbounds=(0.01*pi,0.99*pi),
                doc="The angle of the corner")

    cross = param.Number(default=0.4, bounds=(0,1), softbounds=(0,1),
                doc="Where the two Gaussians cross, as a fraction of their half length")

    def __call__(self,**params_to_override):
github pyviz-dev / nbsite / examples / sites / holoviews / holoviews / plotting / bokeh / View on Github external
import param

from .chart import AreaPlot
from .path import PolygonPlot

class DistributionPlot(AreaPlot):
    DistributionPlot visualizes a distribution of values as a KDE.

    bandwidth = param.Number(default=None, doc="""
        The bandwidth of the kernel for the density estimate.""")

    cut = param.Number(default=3, doc="""
        Draw the estimate to cut * bw from the extreme data points.""")

    filled = param.Boolean(default=True, doc="""
        Whether the bivariate contours should be filled.""")

class BivariatePlot(PolygonPlot):
    Bivariate plot visualizes two-dimensional kernel density
    estimates. Additionally, by enabling the joint option, the
    marginals distributions can be plotted alongside each axis (does
    not animate or compose).
github pyviz-dev / nbsite / examples / sites / holoviews / holoviews / plotting / mpl / View on Github external
The hook is passed the plot object and the displayed
        object, other plotting handles can be accessed via plot.handles.""")

    finalize_hooks = param.HookList(default=[], doc="""
        Optional list of hooks called when finalizing an axis.
        The hook is passed the plot object and the displayed
        object, other plotting handles can be accessed via plot.handles.""")

    sublabel_format = param.String(default=None, allow_None=True, doc="""
        Allows labeling the subaxes in each plot with various formatters
        including {Alpha}, {alpha}, {numeric} and {roman}.""")

    sublabel_position = param.NumericTuple(default=(-0.35, 0.85), doc="""
         Position relative to the plot for placing the optional subfigure label.""")

    sublabel_size = param.Number(default=18, doc="""
         Size of optional subfigure label.""")

    projection = param.Parameter(default=None, doc="""
        The projection of the plot axis, default of None is equivalent to
        2D plot, '3d' and 'polar' are also supported by matplotlib by default.
        May also supply a custom projection that is either a matplotlib
        projection type or implements the `_as_mpl_axes` method.""")

    show_frame = param.Boolean(default=False, doc="""
        Whether or not to show a complete frame around the plot.""")

    _close_figures = True

    def __init__(self, fig=None, axis=None, **params):
        self._create_fig = True
        super(MPLPlot, self).__init__(**params)
github holoviz / holoviews / holoviews / plotting / mpl / View on Github external
import numpy as np

from matplotlib.collections import LineCollection, PolyCollection

from import Dataset
from ...core.options import Cycle, abbreviated_exception
from ...core.util import basestring, unique_array, search_indices, max_range, is_number, isscalar
from ...util.transform import dim
from ..util import process_cmap, get_directed_graph_paths
from .element import ColorbarPlot
from .util import filter_styles

class GraphPlot(ColorbarPlot):

    arrowhead_length = param.Number(default=0.025, doc="""
      If directed option is enabled this determines the length of the
      arrows as fraction of the overall extent of the graph.""")

    directed = param.Boolean(default=False, doc="""
      Whether to draw arrows on the graph edges to indicate the
      directionality of each edge.""")

    # Deprecated options

    color_index = param.ClassSelector(default=None, class_=(basestring, int),
                                      allow_None=True, doc="""
        Deprecated in favor of color style mapping, e.g. `node_color=dim('color')`""")

    edge_color_index = param.ClassSelector(default=None, class_=(basestring, int),
                                      allow_None=True, doc="""