How to use the param.Parameter 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 / API1 / testparamdepends.py View on Github external
def setUp(self):
        class P(param.Parameterized):
            a = param.Parameter()
            b = param.Parameter()

            @param.depends('a')
            def single_parameter(self):
                pass

            @param.depends('a:constant')
            def constant(self):
                pass

            @param.depends('a.param')
            def nested(self):
                pass

        self.P = P
github pyviz-topics / imagen / imagen / transferfn / __init__.py View on Github external
Used for transforming an array of intermediate results into a
    final version, by cropping it, normalizing it, squaring it, etc.

    Objects in this class must support being called as a function with
    one matrix argument, and are expected to change that matrix in place.
    """
    __abstract = True

    init_keys = param.List(default=[], constant=True, doc="""
        List of item key labels for metadata that that must be
        supplied to the initialize method before the TransferFn may be
        used.""")

    # CEBALERT: can we have this here - is there a more appropriate
    # term for it, general to output functions?  JAB: Please do rename it!
    norm_value = param.Parameter(default=None)

    def initialize(self,  **kwargs):
        """
        Transfer functions may need additional information before the
        supplied numpy array can be modified in place. For instance,
        transfer functions may have state which needs to be allocated
        in memory with a certain size. In other cases, the transfer
        function may need to know about the coordinate system
        associated with the input data.
        """
        if not set(kwargs.keys()).issuperset(self.init_keys):
            raise Exception("TransferFn needs to be initialized with %s"
                            % ','.join(repr(el) for el in self.init_keys))

    def __call__(self,x):
        raise NotImplementedError
github pyviz-topics / EarthSim / earthsim / gssha / __init__.py View on Github external
Support for running GSSHA simulations, using Quest.
"""

from datetime import datetime, timedelta

import param
import quest
import geopandas as gpd

from .model import CreateModel, CreateGSSHAModel


class Simulation(param.Parameterized):
    """Basic example of wrapping a GSSHA-based rainfall simulation."""
    
    elevation_service = param.Parameter(default='svc://usgs-ned:13-arc-second',precedence=0.1)
    
    land_use_service = param.Parameter(default='svc://usgs-nlcd:2011',precedence=0.2)

    land_use_grid_id = param.Parameter(default='nlcd',precedence=0.3)
    
    model_creator = param.ClassSelector(CreateModel,default=CreateGSSHAModel(),precedence=-1)

    # TODO: switch to date range...
    simulation_start=param.Date(default=datetime(2017, 5 ,9),precedence=0.5)
    # ...or at least a timedelta parameter type
    simulation_duration=param.Integer(default=120, bounds=(0,None), softbounds=(0,1000000), precedence=0.51, doc="""
        Simulated-time duration to run the simulator, in seconds.""")

    rain_intensity= param.Integer(default=24, bounds=(0,None), softbounds=(0,75), precedence=0.6, doc="""
        Intensity for simulated rain, in mm/hr.""")
github holoviz / holoviews / holoviews / core / options.py View on Github external
compositor.

    For instance, a compositor may be defined to automatically display
    three overlaid monochrome matrices as an RGB image as long as the
    values names of those matrices match 'R', 'G' and 'B'.
    """

    mode = param.ObjectSelector(default='data',
                                objects=['data', 'display'], doc="""
      The mode of the Compositor object which may be either 'data' or
      'display'.""")

    backends = param.List(default=[], doc="""
      Defines which backends to apply the Compositor for.""")

    operation = param.Parameter(doc="""
       The Operation to apply when collapsing overlays.""")

    pattern = param.String(doc="""
       The overlay pattern to be processed. An overlay pattern is a
       sequence of elements specified by dotted paths separated by * .

       For instance the following pattern specifies three overlayed
       matrices with values of 'RedChannel', 'GreenChannel' and
       'BlueChannel' respectively:

      'Image.RedChannel * Image.GreenChannel * Image.BlueChannel.

      This pattern specification could then be associated with the RGB
      operation that returns a single RGB matrix for display.""")

    group = param.String(allow_None=True, doc="""
github holoviz / geoviews / geoviews / plotting / mpl / __init__.py View on Github external
return ret



class GeoPlot(ProjectionPlot, ElementPlot):
    """
    Plotting baseclass for geographic plots with a cartopy projection.
    """

    apply_ranges = param.Boolean(default=False, doc="""
        Do not use ranges to compute plot extents by default.""")

    global_extent = param.Boolean(default=False, doc="""
        Whether the plot should display the whole globe.""")

    projection = param.Parameter(default=ccrs.PlateCarree())

    # Project operation to apply to the element
    _project_operation = None

    def __init__(self, element, **params):
        if 'projection' not in params:
            el = element.last if isinstance(element, HoloMap) else element
            params['projection'] = el.crs
        super(GeoPlot, self).__init__(element, **params)
        plot_opts = self.lookup_options(self.hmap.last, 'plot').options
        self.geographic = is_geographic(self.hmap.last)
        if 'aspect' not in plot_opts:
            self.aspect = 'equal' if self.geographic else 'square'

    def _process_grid(self, gl):
        if not self.show_grid:
github holoviz / holoviews / holoviews / plotting / mpl / heatmap.py View on Github external
ymarks = param.Parameter(default=None, doc="""
        Add separation lines to the heatmap for better readability. By
        default, does not show any separation lines. If parameter is of type
        integer, draws the given amount of separations lines spread across
        heatmap. If parameter is of type list containing integers, show
        separation lines at given indices. If parameter is of type tuple, draw
        separation lines at given categorical values. If parameter is of type
        function, draw separation lines where function returns True for passed
        heatmap category.""")

    xticks = param.Parameter(default=20, doc="""
        Ticks along x-axis/segments specified as an integer, explicit list of
        ticks or function. If `None`, no ticks are shown.""")

    yticks = param.Parameter(default=20, doc="""
        Ticks along y-axis/annulars specified as an integer, explicit list of
        ticks or function. If `None`, no ticks are shown.""")


    def get_extents(self, element, ranges, range_type='combined'):
        ys, xs = element.gridded.interface.shape(element.gridded, gridded=True)
        return (0, 0, xs, ys)


    @classmethod
    def is_radial(cls, heatmap):
        heatmap = heatmap.last if isinstance(heatmap, HoloMap) else heatmap
        opts = cls.lookup_options(heatmap, 'plot').options
        return ((any(o in opts for o in ('start_angle', 'radius_inner', 'radius_outer'))
                 and not (opts.get('radial') == False)) or opts.get('radial', False))
github holoviz / holoviews / holoviews / plotting / bokeh / heatmap.py View on Github external
separation lines at given indices. If parameter is of type tuple, draw
        separation lines at given annular values. If parameter is of type
        function, draw separation lines where function returns True for passed
        annular value.""")

    max_radius = param.Number(default=0.5, doc="""
        Define the maximum radius which is used for the x and y range extents.
        """)

    radial = param.Boolean(default=True, doc="""
        Whether the HeatMap should be radial""")

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

    xticks = param.Parameter(default=4, doc="""
        Ticks along x-axis/segments specified as an integer, explicit list of
        ticks or function. If `None`, no ticks are shown.""")

    yticks = param.Parameter(default=4, doc="""
        Ticks along y-axis/annulars specified as an integer, explicit list of
        ticks or function. If `None`, no ticks are shown.""")

    yrotation = param.Number(default=90, doc="""
        Define angle along which yticks/annulars are shown. By default, yticks
        are drawn like a regular y-axis.""")

    # Map each glyph to a style group
    _style_groups = {'annular_wedge': 'annular',
                     'text': 'ticks',
                     'multi_line': 'xmarks',
                     'arc': 'ymarks'}
github holoviz / holoviews / holoviews / plotting / mpl / element.py View on Github external
zformatter = param.ClassSelector(
        default=None, class_=(util.basestring, ticker.Formatter, FunctionType), doc="""
        Formatter for ticks along the z-axis.""")

    zaxis = param.Boolean(default=True, doc="""
        Whether to display the z-axis.""")

    zlabel = param.String(default=None, doc="""
        An explicit override of the z-axis label, if set takes precedence
        over the dimension label.""")

    zrotation = param.Integer(default=0, bounds=(0, 360), doc="""
        Rotation angle of the zticks.""")

    zticks = param.Parameter(default=None, doc="""
        Ticks along z-axis specified as an integer, explicit list of
        tick locations, list of tuples containing the locations and
        labels or a matplotlib tick locator object. If set to None
        default matplotlib ticking behavior is applied.""")

    # Element Plots should declare the valid style options for matplotlib call
    style_opts = []

    # Declare which styles cannot be mapped to a non-scalar dimension
    _nonvectorized_styles = ['marker', 'alpha', 'cmap', 'angle', 'visible']

    # Whether plot has axes, disables setting axis limits, labels and ticks
    _has_axes = True

    def __init__(self, element, **params):
        super(ElementPlot, self).__init__(element, **params)
github holoviz / param / numbergen / __init__.py View on Github external
If declared time_dependent, the random state is fully determined
    by a hash value per call. The hash is initialized once with the
    object name and then per call using a tuple consisting of the time
    (via time_fn) and the global param.random_seed.  As a consequence,
    for a given name and fixed value of param.random_seed, the random
    values generated will be a fixed function of time.

    If the object name has not been set and time_dependent is True, a
    message is generated warning that the default object name is
    dependent on the order of instantiation.  To ensure that the
    random number stream will remain constant even if other objects
    are added or reordered in your file, supply a unique name
    explicitly when you construct the RandomDistribution object.
    """

    random_generator = param.Parameter(
        default=random.Random((500,500)), doc=
        """
        Random state used by the object. This may may be an instance
        of random.Random from the Python standard library or an
        instance of numpy.random.RandomState.

        This random state may be exclusively owned by the object or
        may be shared by all instance of the same class. It is always
        possible to give an object its own unique random state by
        setting this parameter with a new random state instance.
        """)

    __abstract = True

    def _initialize_random_state(self, seed=None, shared=True, name=None):
        """
github holoviz / panel / panel / layout.py View on Github external
class WidgetBox(ListPanel):
    """
    Vertical layout of widgets.
    """

    css_classes = param.List(default=['widget-box'], doc="""
        CSS classes to apply to the layout.""")

    disabled = param.Boolean(default=False, doc="""
        Whether the widget is disabled.""")

    horizontal = param.Boolean(default=False, doc="""
        Whether to lay out the widgets in a Row layout as opposed 
        to a Column layout.""")

    margin = param.Parameter(default=5, doc="""
        Allows to create additional space around the component. May
        be specified as a two-tuple of the form (vertical, horizontal)
        or a four-tuple (top, right, bottom, left).""")

    _source_transforms = {'disabled': None, 'horizontal': None}

    _rename = {'objects': 'children', 'horizontal': None}

    @property
    def _bokeh_model(self):
        return BkRow if self.horizontal else BkColumn

    @param.depends('disabled', 'objects', watch=True)
    def _disable_widgets(self):
        for obj in self:
            if hasattr(obj, 'disabled'):