How to use the param.ParamOverrides 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 / holoviews / tests / core / testcallable.py View on Github external
def __call__(self, a, **params):
        p = param.ParamOverrides(self, params)
        return a * p.b
github erdc / quest / quest_provider_plugins / usgs_nwis.py View on Github external
def download(self, catalog_id, file_path, dataset, **kwargs):
        p = param.ParamOverrides(self, kwargs)

        parameter = p.parameter
        start = p.start
        end = p.end
        period = p.period

        if dataset is None:
            dataset = 'station-' + catalog_id

        if start and end:
            period = None

        pmap = self.parameter_map(invert=True)
        parameter_code, statistic_code = (pmap[parameter].split(':') + [None])[:2]

        data = nwis.get_site_data(catalog_id,
github pyviz-dev / nbsite / examples / sites / holoviews / holoviews / util / __init__.py View on Github external
def __call__(self, map_obj, **params):
        self.p = param.ParamOverrides(self, params)
        callback = self._dynamic_operation(map_obj)
        streams = self._get_streams(map_obj)
        if isinstance(map_obj, DynamicMap):
            dmap = map_obj.clone(callback=callback, shared_data=self.p.shared_data,
                                 streams=streams)
        else:
            dmap = self._make_dynamic(map_obj, callback, streams)
        return dmap
github holoviz / holoviews / holoviews / ipython / __init__.py View on Github external
try:
                from .archive import notebook_archive
                holoviews.archive = notebook_archive
            except AttributeError as e:
                if str(e) != "module 'tornado.web' has no attribute 'asynchronous'":
                    raise

        except ImportError:
            pass

        # Not quite right, should be set when switching backends
        if 'matplotlib' in Store.renderers and not notebook_extension._loaded:
            svg_exporter = Store.renderers['matplotlib'].instance(holomap=None,fig='svg')
            holoviews.archive.exporters = [svg_exporter] + holoviews.archive.exporters

        p = param.ParamOverrides(self, {k:v for k,v in params.items() if k!='config'})
        if p.case_sensitive_completion:
            from IPython.core import completer
            completer.completions_sorting_key = self.completions_sorting_key
        if not p.allow_jedi_completion and hasattr(IPCompleter, 'use_jedi'):
            ip.run_line_magic('config', 'IPCompleter.use_jedi = False')

        resources = self._get_resources(args, params)

        Store.display_formats = p.display_formats
        if 'html' not in p.display_formats and len(p.display_formats) > 1:
            msg = ('Output magic unable to control displayed format '
                   'as IPython notebook uses fixed precedence '
                   'between %r' % p.display_formats)
            display(HTML('<b>Warning</b>: %s' % msg))

        loaded = notebook_extension._loaded
github holoviz / holoviews / holoviews / util / __init__.py View on Github external
def __call__(self, map_obj, **params):
        self.p = param.ParamOverrides(self, params)
        callback = self._dynamic_operation(map_obj)
        streams = self._get_streams(map_obj)
        if isinstance(map_obj, DynamicMap):
            dmap = map_obj.clone(callback=callback, shared_data=self.p.shared_data,
                                 streams=streams)
        else:
            dmap = self._make_dynamic(map_obj, callback, streams)
        return dmap
github holoviz / datashader / datashader / layout.py View on Github external
def __call__(self, nodes, edges, **params):
        p = param.ParamOverrides(self, params)

        np.random.seed(p.seed)

        # Convert graph into sparse adjacency matrix and array of points
        points = _extract_points_from_nodes(nodes, p, dtype='f')
        matrix = _convert_graph_to_sparse_matrix(nodes, edges, p, dtype='f')

        if p.k is None:
            p.k = np.sqrt(1.0 / len(points))

        # the initial "temperature" is about .1 of domain area (=1x1)
        # this is the largest step allowed in the dynamics.
        temperature = 0.1

        # simple cooling scheme.
        # linearly step down by dt on each iteration so last iteration is size dt.
github ioam / paramnb / paramnb / __init__.py View on Github external
def __call__(self, parameterized, plots=[],  **params):
        self.p = param.ParamOverrides(self, params)
        if self.p.initializer:
            self.p.initializer(parameterized)

        self._id = uuid.uuid4().hex
        self._widgets = {}
        self.parameterized = parameterized

        widgets, views = self.widgets()
        layout = ipywidgets.Layout(display='flex', flex_flow=self.p.layout)
        if self.p.close_button:
            layout.border = 'solid 1px'

        widget_box = ipywidgets.VBox(children=widgets, layout=layout)
        plot_outputs = tuple(Output() for p in plots)
        if views or plots:
            outputs = tuple(views.values()) + plot_outputs
github holoviz / holoviews / dataviews / plots.py View on Github external
def __call__(self, view, **params):
        anim_exts = ['.webm', '.mp4', 'gif']
        image_exts = ['.png', '.jpg', '.svg']
        writers = {'.mp4': 'ffmpeg', '.webm':'ffmpeg', '.gif':'imagemagick'}
        supported_extensions = image_exts + anim_exts

        self.p = param.ParamOverrides(self, params, allow_extra_keywords=True)
        if self.p.filename is None:
            raise Exception("Please supply a suitable filename.")

        _, ext = os.path.splitext(self.p.filename)
        if ext not in supported_extensions:
            valid_exts = ', '.join(supported_extensions)
            raise Exception("File of type %r not in %s" % (ext, valid_exts))
        file_format = ext[1:]

        plottype = Plot.defaults[type(view)]
        plotopts = View.options.plotting(view).opts
        plot = plottype(view, **dict(plotopts, size=self.p.size))

        if len(plot) > 1 and ext in anim_exts:
            anim_kwargs, extra_args = self.p.anim_opts[ext]
            anim = plot.anim(**self.p.extra_keywords())
github pyviz-topics / EarthSim / earthsim / gssha / model.py View on Github external
def __call__(self,**params):
        p = param.ParamOverrides(self,params)
        return GSSHAModel(**self._map_kw(p))
github ioam / lancet / lancet / __init__.py View on Github external
def __call__(self, paths=[], **params_to_override):
        """
        Takes a single path string or a list of path strings and
        returns the corresponing version control information.
        """
        p=param.ParamOverrides(self, dict(params_to_override, paths=paths))
        if p.paths == []:
            raise Exception("No paths to version controlled repositories given.")

        paths = [p.paths] if isinstance(p.paths, str) else p.paths

        def _desc(path, ind):
            for vcs in p.commands.keys():
                if os.path.exists(os.path.join(path, vcs)):
                    proc = subprocess.Popen(p.commands[vcs][ind],
                                            stdout=subprocess.PIPE,
                                            stderr=subprocess.PIPE, cwd=path)
                    return str(proc.communicate()[0].decode()).strip()

        abspaths = [os.path.abspath(path) for path in paths]
        return {'vcs_versions' : dict((path, _desc(path,0)) for path in abspaths),
                'vcs_messages':  dict((path, _desc(path,1)) for path in abspaths),