Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_initialization_out_of_bounds(self):
try:
class Q(param.Parameterized):
q = param.ObjectSelector(5,objects=[4])
except ValueError:
pass
else:
raise AssertionError("ObjectSelector created outside range.")
merge_tools = param.Boolean(default=True, doc="""
Whether to merge all the tools into a single toolbar""")
shared_xaxis = param.Boolean(default=False, doc="""
If enabled the x-axes of the GridSpace will be drawn from the
objects inside the Grid rather than the GridSpace dimensions.""")
shared_yaxis = param.Boolean(default=False, doc="""
If enabled the x-axes of the GridSpace will be drawn from the
objects inside the Grid rather than the GridSpace dimensions.""")
show_legend = param.Boolean(default=False, doc="""
Adds a legend based on the entries of the middle-right plot""")
xaxis = param.ObjectSelector(default=True,
objects=['bottom', 'top', None, True, False], doc="""
Whether and where to display the xaxis, supported options are
'bottom', 'top' and None.""")
yaxis = param.ObjectSelector(default=True,
objects=['left', 'right', None, True, False], doc="""
Whether and where to display the yaxis, supported options are
'left', 'right' and None.""")
xrotation = param.Integer(default=0, bounds=(0, 360), doc="""
Rotation angle of the xticks.""")
yrotation = param.Integer(default=0, bounds=(0, 360), doc="""
Rotation angle of the yticks.""")
plot_size = param.ClassSelector(default=120, class_=(int, tuple), doc="""
size = param.NumericTuple(default=(5, 5), doc="""
The matplotlib figure size in inches.""")
show_frame = param.Boolean(default=True, doc="""
Whether or not to show a complete frame around the plot.""")
show_grid = param.Boolean(default=False, doc="""
Whether to show a Cartesian grid on the plot.""")
show_legend = param.Boolean(default=True, doc="""
Whether to show legend for the plot.""")
show_title = param.Boolean(default=True, doc="""
Whether to display the plot title.""")
show_xaxis = param.ObjectSelector(default='bottom',
objects=['top', 'bottom', None], doc="""
Whether and where to display the xaxis.""")
show_yaxis = param.ObjectSelector(default='left',
objects=['left', 'right', None], doc="""
Whether and where to display the yaxis.""")
style_opts = param.List(default=[], constant=True, doc="""
A list of matplotlib keyword arguments that may be supplied via a
style options object. Each subclass should override this
parameter to list every option that works correctly.""")
aspect = param.ObjectSelector(default=None,
objects=['auto', 'equal','square', None],
doc="""
The aspect ratio mode of the plot. By default, a plot may select
bar_color = param.Color(default="#e6e6e6", doc="""
Color of the slider bar as a hexidecimal RGB value.""")
callback_policy = param.ObjectSelector(
default='continuous', objects=['continuous', 'throttle', 'mouseup'], doc="""
Policy to determine when slider events are triggered:
* "continuous": the callback will be executed immediately for each movement of the slider
* "throttle": the callback will be executed at most every ``callback_throttle`` milliseconds.
* "mouseup": the callback will be executed only once when the slider is released.
""")
callback_throttle = param.Integer(default=200, doc="""
Number of milliseconds to pause between callback calls as the slider is moved.""")
direction = param.ObjectSelector(default='ltr', objects=['ltr', 'rtl'],
doc="""
Whether the slider should go from left-to-right ('ltr') or right-to-left ('rtl')""")
orientation = param.ObjectSelector(default='horizontal',
objects=['horizontal', 'vertical'], doc="""
Whether the slider should be oriented horizontally or vertically.""")
tooltips = param.Boolean(default=True, doc="""
Whether the slider handle should display tooltips""")
class FloatSlider(_SliderBase):
start = param.Number(default=0.0)
end = param.Number(default=1.0)
def _init_glyph(self, plot, mapping, properties):
"""
Returns a Bokeh glyph object and optionally creates a colorbar.
"""
ret = super(ColorbarPlot, self)._init_glyph(plot, mapping, properties)
if self.colorbar:
for k, v in list(self.handles.items()):
if not k.endswith('color_mapper'):
continue
self._draw_colorbar(plot, v, k[:-12])
return ret
class LegendPlot(ElementPlot):
legend_position = param.ObjectSelector(objects=["top_right",
"top_left",
"bottom_left",
"bottom_right",
'right', 'left',
'top', 'bottom'],
default="top_right",
doc="""
Allows selecting between a number of predefined legend position
options. The predefined options may be customized in the
legend_specs class attribute.""")
legend_muted = param.Boolean(default=False, doc="""
Controls whether the legend entries are muted by default.""")
legend_offset = param.NumericTuple(default=(0, 0), doc="""
If legend is placed outside the axis, this determines the
return msg
class ColorPicker(Widget):
value = param.Color(default=None, doc="""
The selected color""")
_widget_type = _BkColorPicker
_rename = {'value': 'color', 'name': 'title'}
class _ButtonBase(Widget):
button_type = param.ObjectSelector(default='default', objects=[
'default', 'primary', 'success', 'info', 'danger'])
_rename = {'name': 'label'}
class Button(_ButtonBase):
clicks = param.Integer(default=0)
_widget_type = _BkButton
def on_click(self, callback):
self.param.watch(callback, 'clicks')
class Toggle(_ButtonBase):
# Load data
ddf = dd.read_parquet(os.path.join(os.path.dirname(__file__),'..','..','..','data','nyc_taxi_wide.parq', engine='fastparquet')).persist()
tiles = EsriImagery()
stream = hv.streams.Stream.define('HourSelect', hour=0)()
points = hv.Points(ddf, kdims=['dropoff_x', 'dropoff_y'])
dmap = hv.util.Dynamic(points, operation=lambda obj, hour: obj.select(dropoff_hour=hour).relabel('Hour of Day: %d' % hour),
streams=[stream])
# Apply aggregation
aggregated = aggregate(dmap, link_inputs=True, streams=[hv.streams.RangeXY], width=1200, height=600)
# Shade the data
class ColormapPicker(hv.streams.Stream):
colormap = param.ObjectSelector(default=cm_n["fire"], objects=cm_n.values())
cmap_picker = ColormapPicker(rename={'colormap': 'cmap'}, name='')
shaded = shade(aggregated, link_inputs=True, streams=[cmap_picker])
# Define PointerX stream, attach to points and declare DynamicMap for cross-section and VLine
pointer = hv.streams.PointerX(x=ddf.dropoff_x.loc[0].compute().iloc[0], source=points)
section = hv.util.Dynamic(aggregated, operation=lambda obj, x: obj.sample(dropoff_x=x),
streams=[pointer], link_inputs=False).relabel('')
vline = hv.DynamicMap(lambda x: hv.VLine(x), streams=[pointer])
# Define options
hv.opts("RGB [width=1200 height=600 xaxis=None yaxis=None fontsize={'title': '14pt'}] VLine (color='white' line_width=2)")
hv.opts("Curve [width=150 yaxis=None show_frame=False] (color='black') {+framewise} Layout [shared_axes=False]")
# Combine it all into a complex layout
hvobj = (tiles * shaded * vline) << section
pass
from ...core.options import abbreviated_exception, SkipRendering
from ...core.util import basestring, dimension_sanitizer
from .chart import ColorbarPlot, PointPlot
from .element import CompositeElementPlot, LegendPlot, line_properties, fill_properties, property_prefixes
from .util import mpl_to_bokeh
class GraphPlot(CompositeElementPlot, ColorbarPlot, LegendPlot):
color_index = param.ClassSelector(default=None, class_=(basestring, int),
allow_None=True, doc="""
Index of the dimension from which the color will the drawn""")
selection_policy = param.ObjectSelector(default='nodes', objects=['edges', 'nodes', None], doc="""
Determines policy for inspection of graph components, i.e. whether to highlight
nodes or edges when selecting connected edges and nodes respectively.""")
inspection_policy = param.ObjectSelector(default='nodes', objects=['edges', 'nodes', None], doc="""
Determines policy for inspection of graph components, i.e. whether to highlight
nodes or edges when hovering over connected edges and nodes respectively.""")
tools = param.List(default=['hover', 'tap'], doc="""
A list of plugin tools to use on the plot.""")
# X-axis is categorical
_x_range_type = Range1d
# Declare that y-range should auto-range if not bounded
_y_range_type = Range1d
TOOL_TYPES, bokeh_version, date_to_integer, decode_bytes, get_tab_title,
glyph_order, py2js_tickformatter, recursive_model_update,
theme_attr_json, cds_column_replace, hold_policy, match_dim_specs,
compute_layout_properties, wrap_formatter)
class ElementPlot(BokehPlot, GenericElementPlot):
active_tools = param.List(default=[], doc="""
Allows specifying which tools are active by default. Note
that only one tool per gesture type can be active, e.g.
both 'pan' and 'box_zoom' are drag tools, so if both are
listed only the last one will be active.""")
align = param.ObjectSelector(default=None, objects=['start', 'center', 'end'], doc="""
Alignment (vertical or horizontal) of the plot in a layout.""")
border = param.Number(default=10, doc="""
Minimum border around plot.""")
aspect = param.Parameter(default=None, doc="""
The aspect ratio mode of the plot. By default, a plot may
select its own appropriate aspect ratio but sometimes it may
be necessary to force a square aspect ratio (e.g. to display
the plot as an element of a grid). The modes 'auto' and
'equal' correspond to the axis modes of the same name in
matplotlib, a numeric value specifying the ratio between plot
width and height may also be passed. To control the aspect
ratio between the axis scales use the data_aspect option
instead.""")
Note that if you are using Python 3, you can switch to version 2
for compatibility but you cannot enable relaxed sanitization if
you are using Python 2.
Special characters are sanitized using their (lowercase) unicode
name using the unicodedata module. For instance:
>>> unicodedata.name(u'$').lower()
'dollar sign'
As these names are often very long, this parameterized function
allows filtered, substitutions and transforms to help shorten these
names appropriately.
"""
version = param.ObjectSelector(sys.version_info.major, objects=[2,3], doc="""
The sanitization version. If set to 2, more aggressive
sanitization appropriate for Python 2 is applied. Otherwise,
if set to 3, more relaxed, Python 3 sanitization is used.""")
capitalize = param.Boolean(default=True, doc="""
Whether the first letter should be converted to
uppercase. Note, this will only be applied to ASCII characters
in order to make sure paths aren't confused with method
names.""")
eliminations = param.List(['extended', 'accent', 'small', 'letter', 'sign', 'digit',
'latin', 'greek', 'arabic-indic', 'with', 'dollar'], doc="""
Lowercase strings to be eliminated from the unicode names in
order to shorten the sanitized name ( lowercase). Redundant
strings should be removed but too much elimination could cause
two unique strings to map to the same sanitized output.""")