SHA256
1
0
forked from pool/python-bokeh

Accepting request 907320 from home:bnavigator:branches:devel:languages:python:numeric

Ok I should have removed the URL after rebasing the patch

OBS-URL: https://build.opensuse.org/request/show/907320
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-bokeh?expand=0&rev=50
This commit is contained in:
Matej Cepl 2021-07-20 15:40:42 +00:00 committed by Git OBS Bridge
parent e99a08c513
commit 29b40fad85
2 changed files with 131 additions and 200 deletions

View File

@ -11,11 +11,11 @@ Subject: [PATCH 1/2] Unify {Figure,Toolbar}.active_* properties
bokehjs/src/lib/models/tools/toolbar.ts | 18 ++++++------- bokehjs/src/lib/models/tools/toolbar.ts | 18 ++++++-------
5 files changed, 46 insertions(+), 29 deletions(-) 5 files changed, 46 insertions(+), 29 deletions(-)
diff --git a/bokeh/models/tools.py b/bokeh/models/tools.py Index: bokeh-2.3.3/bokeh/models/tools.py
index 937f7852ce8..96d6c2798ee 100644 ===================================================================
--- a/bokeh/models/tools.py --- bokeh-2.3.3.orig/bokeh/models/tools.py
+++ b/bokeh/models/tools.py +++ bokeh-2.3.3/bokeh/models/tools.py
@@ -314,7 +314,7 @@ class Toolbar(ToolbarBase): @@ -305,7 +305,7 @@ class Toolbar(ToolbarBase):
Specify a tap/click tool to be active when the plot is displayed. Specify a tap/click tool to be active when the plot is displayed.
""") """)
@ -24,19 +24,20 @@ index 937f7852ce8..96d6c2798ee 100644
Specify an active multi-gesture tool, for instance an edit tool or a range Specify an active multi-gesture tool, for instance an edit tool or a range
tool. tool.
diff --git a/bokeh/plotting/_tools.py b/bokeh/plotting/_tools.py Index: bokeh-2.3.3/bokeh/plotting/_tools.py
index 53c8b035753..1fa243776b1 100644 ===================================================================
--- a/bokeh/plotting/_tools.py --- bokeh-2.3.3.orig/bokeh/plotting/_tools.py
+++ b/bokeh/plotting/_tools.py +++ bokeh-2.3.3/bokeh/plotting/_tools.py
@@ -44,6 +44,7 @@ @@ -37,7 +37,7 @@ from typing_extensions import Literal
)
from ..models.tools import ( # Bokeh imports
Drag, from ..models import HoverTool, Plot, Tool, Toolbar
+ GestureTool, -from ..models.tools import Drag, InspectTool, Scroll, Tap
InspectTool, +from ..models.tools import Drag, GestureTool, InspectTool, Scroll, Tap
Scroll,
Tap, #-----------------------------------------------------------------------------
@@ -72,18 +73,21 @@ # Globals and constants
@@ -62,18 +62,21 @@ ActiveDrag = Union[Drag, Auto, str, None
ActiveInspect = Union[List[InspectTool], InspectTool, Auto, str, None] ActiveInspect = Union[List[InspectTool], InspectTool, Auto, str, None]
ActiveScroll = Union[Scroll, Auto, str, None] ActiveScroll = Union[Scroll, Auto, str, None]
ActiveTap = Union[Tap, Auto, str, None] ActiveTap = Union[Tap, Auto, str, None]
@ -63,7 +64,7 @@ index 53c8b035753..1fa243776b1 100644
Returns: Returns:
None None
@@ -91,12 +95,12 @@ def process_active_tools(toolbar: Toolbar, tool_map: Dict[str, Tool], @@ -81,12 +84,12 @@ def process_active_tools(toolbar: Toolba
Note: Note:
This function sets properties on Toolbar This function sets properties on Toolbar
""" """
@ -78,7 +79,7 @@ index 53c8b035753..1fa243776b1 100644
if active_inspect in ["auto", None] or isinstance(active_inspect, Tool) or \ if active_inspect in ["auto", None] or isinstance(active_inspect, Tool) or \
(isinstance(active_inspect, list) and all(isinstance(t, Tool) for t in active_inspect)): (isinstance(active_inspect, list) and all(isinstance(t, Tool) for t in active_inspect)):
@@ -104,21 +108,28 @@ def process_active_tools(toolbar: Toolbar, tool_map: Dict[str, Tool], @@ -94,21 +97,28 @@ def process_active_tools(toolbar: Toolba
elif isinstance(active_inspect, str) and active_inspect in tool_map: elif isinstance(active_inspect, str) and active_inspect in tool_map:
toolbar.active_inspect = cast(Any, tool_map[active_inspect]) toolbar.active_inspect = cast(Any, tool_map[active_inspect])
else: else:
@ -112,29 +113,59 @@ index 53c8b035753..1fa243776b1 100644
def process_tools_arg(plot: Plot, tools: Union[str, Sequence[Union[Tool, str]]], def process_tools_arg(plot: Plot, tools: Union[str, Sequence[Union[Tool, str]]],
tooltips: Optional[Union[str, Tuple[str, str]]] = None) -> Tuple[List[Tool], Dict[str, Tool]]: tooltips: Optional[Union[str, Tuple[str, str]]] = None) -> Tuple[List[Tool], Dict[str, Tool]]:
diff --git a/bokeh/plotting/figure.py b/bokeh/plotting/figure.py Index: bokeh-2.3.3/bokeh/plotting/figure.py
index 6e3764a18e1..cf3804507d3 100644 ===================================================================
--- a/bokeh/plotting/figure.py --- bokeh-2.3.3.orig/bokeh/plotting/figure.py
+++ b/bokeh/plotting/figure.py +++ bokeh-2.3.3/bokeh/plotting/figure.py
@@ -41,6 +41,7 @@ @@ -32,7 +32,7 @@ from ..core.properties import (
Tuple,
) )
from ..models.tools import ( from ..models import ColumnDataSource, GraphRenderer, Plot, Title, Tool, glyphs
Drag, -from ..models.tools import Drag, InspectTool, Scroll, Tap
+ GestureTool, +from ..models.tools import Drag, GestureTool, InspectTool, Scroll, Tap
InspectTool, from ..transform import linear_cmap
Scroll, from ..util.options import Options
Tap, from ._decorators import glyph_method, marker_method
@@ -181,7 +182,8 @@ def __init__(self, *arg, **kw): @@ -175,7 +175,15 @@ class Figure(Plot):
tool_objs, tool_map = process_tools_arg(self, opts.tools, opts.tooltips) tool_objs, tool_map = process_tools_arg(self, opts.tools, opts.tooltips)
self.add_tools(*tool_objs) self.add_tools(*tool_objs)
- process_active_tools(self.toolbar, tool_map, opts.active_drag, opts.active_inspect, opts.active_scroll, opts.active_tap) - process_active_tools(self.toolbar, tool_map, opts.active_drag, opts.active_inspect, opts.active_scroll, opts.active_tap)
+ process_active_tools(self.toolbar, tool_map, + process_active_tools(
+ opts.active_drag, opts.active_inspect, opts.active_scroll, opts.active_tap, opts.active_multi) + self.toolbar,
+ tool_map,
+ opts.active_drag,
+ opts.active_inspect,
+ opts.active_scroll,
+ opts.active_tap,
+ opts.active_multi,
+ )
@glyph_method(glyphs.AnnularWedge) @glyph_method(glyphs.AnnularWedge)
def annular_wedge(self, **kwargs): def annular_wedge(self, **kwargs):
@@ -1643,22 +1645,26 @@ class FigureOptions(Options): @@ -1599,20 +1607,12 @@ def markers():
# This class itself is intentionally undocumented (it is used to generate
# documentation elsewhere)
-class FigureOptions(Options):
+class BaseFigureOptions(Options):
tools = Either(String, Seq(Either(String, Instance(Tool))), default=DEFAULT_TOOLS, help="""
Tools the plot should start with.
""")
- x_range = Any(help="""
- Customize the x-range of the plot.
- """)
-
- y_range = Any(help="""
- Customize the y-range of the plot.
- """)
-
x_minor_ticks = Either(Auto, Int, default="auto", help="""
Number of minor ticks between adjacent x-axis major ticks.
""")
@@ -1637,28 +1637,24 @@ class FigureOptions(Options):
A label for the y-axis. A label for the y-axis.
""") """)
@ -158,149 +189,18 @@ index 6e3764a18e1..cf3804507d3 100644
Which tap tool should initially be active. Which tap tool should initially be active.
""") """)
+ active_multi = Either(Null, Auto, String, Instance(GestureTool), default="auto", help="""
+ Specify an active multi-gesture tool, for instance an edit tool or a range tool.
+ """)
+
x_axis_type = Either(Null, Auto, Enum("linear", "log", "datetime", "mercator"), default="auto", help="""
The type of the x-axis.
""")
diff --git a/bokeh/plotting/gmap.py b/bokeh/plotting/gmap.py
index 90dde0c8206..283d018ae97 100644
--- a/bokeh/plotting/gmap.py
+++ b/bokeh/plotting/gmap.py
@@ -105,8 +105,8 @@ def __init__(self, **kw):
tool_objs, tool_map = process_tools_arg(self, opts.tools)
self.add_tools(*tool_objs)
- process_active_tools(self.toolbar, tool_map, opts.active_drag, opts.active_inspect, opts.active_scroll, opts.active_tap)
-
+ process_active_tools(self.toolbar, tool_map,
+ opts.active_drag, opts.active_inspect, opts.active_scroll, opts.active_tap, opts.active_multi)
annular_wedge = Figure.annular_wedge
diff --git a/bokehjs/src/lib/models/tools/toolbar.ts b/bokehjs/src/lib/models/tools/toolbar.ts
index 45463b0e14b..e22cb9b3ad0 100644
--- a/bokehjs/src/lib/models/tools/toolbar.ts
+++ b/bokehjs/src/lib/models/tools/toolbar.ts
@@ -23,7 +23,7 @@ type ActiveGestureToolsProps = {
active_drag: p.Property<Drag | "auto" | null>
active_scroll: p.Property<Scroll | "auto" | null>
active_tap: p.Property<Tap | "auto" | null>
- active_multi: p.Property<GestureTool | null>
+ active_multi: p.Property<GestureTool | "auto" | null>
}
type ActiveToolsProps = ActiveGestureToolsProps & {
@@ -38,7 +38,7 @@ export namespace Toolbar {
export interface Toolbar extends Toolbar.Attrs {}
-const _get_active_attr = (et: string): keyof ActiveGestureToolsProps | null => {
+function _get_active_attr(et: string): keyof ActiveGestureToolsProps | null {
switch (et) {
case 'tap': return 'active_tap'
case 'pan': return 'active_drag'
@@ -49,7 +49,7 @@ const _get_active_attr = (et: string): keyof ActiveGestureToolsProps | null => {
return null
}
-const _supports_auto = (et: string) => {
+function _supports_auto(et: string): boolean {
return et == 'tap' || et == 'pan'
}
@@ -63,12 +63,12 @@ export class Toolbar extends ToolbarBase {
static init_Toolbar(): void {
this.prototype.default_view = ToolbarBaseView
- this.define<Toolbar.Props>(({Or, Ref, Auto, Null, Nullable}) => ({
- active_drag: [ Or(Ref(Drag), Auto, Null), "auto" ],
- active_inspect: [ Or(Ref(Inspection), Auto, Null), "auto" ],
- active_scroll: [ Or(Ref(Scroll), Auto, Null), "auto" ],
- active_tap: [ Or(Ref(Tap), Auto, Null), "auto" ],
- active_multi: [ Nullable(Ref(GestureTool)), null ],
+ this.define<Toolbar.Props>(({Or, Ref, Auto, Null}) => ({
+ active_drag: [ Or(Ref(Drag), Auto, Null), "auto" ],
+ active_inspect: [ Or(Ref(Inspection), Auto, Null), "auto" ],
+ active_scroll: [ Or(Ref(Scroll), Auto, Null), "auto" ],
+ active_tap: [ Or(Ref(Tap), Auto, Null), "auto" ],
+ active_multi: [ Or(Ref(GestureTool), Auto, Null), "auto" ],
}))
}
From 0f30e87af87a282fc7ba7fce56cf2987165b3947 Mon Sep 17 00:00:00 2001
From: Mateusz Paprocki <mattpap@gmail.com>
Date: Wed, 28 Apr 2021 21:50:04 +0200
Subject: [PATCH 2/2] Unify FigureOptions and GMapFigureOptions
---
bokeh/plotting/figure.py | 47 +++++++++++--------
bokeh/plotting/gmap.py | 97 ++++++++++------------------------------
2 files changed, 52 insertions(+), 92 deletions(-)
diff --git a/bokeh/plotting/figure.py b/bokeh/plotting/figure.py
index cf3804507d3..8201fa8deb6 100644
--- a/bokeh/plotting/figure.py
+++ b/bokeh/plotting/figure.py
@@ -182,8 +182,15 @@ def __init__(self, *arg, **kw):
tool_objs, tool_map = process_tools_arg(self, opts.tools, opts.tooltips)
self.add_tools(*tool_objs)
- process_active_tools(self.toolbar, tool_map,
- opts.active_drag, opts.active_inspect, opts.active_scroll, opts.active_tap, opts.active_multi)
+ process_active_tools(
+ self.toolbar,
+ tool_map,
+ opts.active_drag,
+ opts.active_inspect,
+ opts.active_scroll,
+ opts.active_tap,
+ opts.active_multi,
+ )
@glyph_method(glyphs.AnnularWedge)
def annular_wedge(self, **kwargs):
@@ -1607,20 +1614,12 @@ def markers():
# This class itself is intentionally undocumented (it is used to generate
# documentation elsewhere)
-class FigureOptions(Options):
+class BaseFigureOptions(Options):
tools = Either(String, Seq(Either(String, Instance(Tool))), default=DEFAULT_TOOLS, help="""
Tools the plot should start with.
""")
- x_range = Any(help="""
- Customize the x-range of the plot.
- """)
-
- y_range = Any(help="""
- Customize the y-range of the plot.
- """)
-
x_minor_ticks = Either(Auto, Int, default="auto", help="""
Number of minor ticks between adjacent x-axis major ticks.
""")
@@ -1665,14 +1664,6 @@ class FigureOptions(Options):
Specify an active multi-gesture tool, for instance an edit tool or a range tool.
""")
- x_axis_type = Either(Null, Auto, Enum("linear", "log", "datetime", "mercator"), default="auto", help=""" - x_axis_type = Either(Null, Auto, Enum("linear", "log", "datetime", "mercator"), default="auto", help="""
- The type of the x-axis. - The type of the x-axis.
- """) - """)
- -
- y_axis_type = Either(Null, Auto, Enum("linear", "log", "datetime", "mercator"), default="auto", help=""" - y_axis_type = Either(Null, Auto, Enum("linear", "log", "datetime", "mercator"), default="auto", help="""
- The type of the y-axis. - The type of the y-axis.
- """) + active_multi = Either(Null, Auto, String, Instance(GestureTool), default="auto", help="""
- + Specify an active multi-gesture tool, for instance an edit tool or a range tool.
""")
tooltips = Either(Null, String, List(Tuple(String, String)), help=""" tooltips = Either(Null, String, List(Tuple(String, String)), help="""
An optional argument to configure tooltips for the Figure. This argument @@ -1670,6 +1666,24 @@ class FigureOptions(Options):
accepts the same values as the ``HoverTool.tooltips`` property. If a hover
@@ -1682,6 +1673,24 @@ class FigureOptions(Options):
and added. and added.
""") """)
@ -325,39 +225,26 @@ index cf3804507d3..8201fa8deb6 100644
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Private API # Private API
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
diff --git a/bokeh/plotting/gmap.py b/bokeh/plotting/gmap.py Index: bokeh-2.3.3/bokeh/plotting/gmap.py
index 283d018ae97..2073a456a86 100644 ===================================================================
--- a/bokeh/plotting/gmap.py --- bokeh-2.3.3.orig/bokeh/plotting/gmap.py
+++ b/bokeh/plotting/gmap.py +++ bokeh-2.3.3/bokeh/plotting/gmap.py
@@ -16,16 +16,6 @@ @@ -16,8 +16,6 @@ log = logging.getLogger(__name__)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Bokeh imports # Bokeh imports
-from ..core.enums import HorizontalLocation, VerticalLocation -from ..core.enums import HorizontalLocation, VerticalLocation
-from ..core.properties import ( -from ..core.properties import Auto, Either, Enum, Instance, Int, Seq, String
- Auto,
- Either,
- Enum,
- Instance,
- Int,
- Seq,
- String,
-)
from ..models import ( from ..models import (
GMapPlot, GMapPlot,
LinearAxis, LinearAxis,
@@ -33,17 +23,10 @@ @@ -25,12 +23,10 @@ from ..models import (
MercatorTickFormatter, MercatorTickFormatter,
Range1d, Range1d,
Title, Title,
- Tool, - Tool,
-)
-from ..models.tools import (
- Drag,
- InspectTool,
- Scroll,
- Tap,
) )
-from ..models.tools import Drag, InspectTool, Scroll, Tap
-from ..util.options import Options -from ..util.options import Options
+from ._plot import _get_num_minor_ticks +from ._plot import _get_num_minor_ticks
from ._tools import process_active_tools, process_tools_arg from ._tools import process_active_tools, process_tools_arg
@ -366,22 +253,23 @@ index 283d018ae97..2073a456a86 100644
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Globals and constants # Globals and constants
@@ -95,18 +78,29 @@ def __init__(self, **kw): @@ -92,18 +88,29 @@ class GMap(GMapPlot):
super().__init__(x_range=Range1d(), y_range=Range1d(), **kw) super().__init__(x_range=Range1d(), y_range=Range1d(), **kw)
- xf = MercatorTickFormatter(dimension="lon") - xf = MercatorTickFormatter(dimension="lon")
- xt = MercatorTicker(dimension="lon") - xt = MercatorTicker(dimension="lon")
- self.add_layout(LinearAxis(formatter=xf, ticker=xt), 'below') - self.add_layout(LinearAxis(formatter=xf, ticker=xt), 'below')
-
- yf = MercatorTickFormatter(dimension="lat")
- yt = MercatorTicker(dimension="lat")
- self.add_layout(LinearAxis(formatter=yf, ticker=yt), 'left')
+ if opts.x_axis_location is not None: + if opts.x_axis_location is not None:
+ xf = MercatorTickFormatter(dimension="lon") + xf = MercatorTickFormatter(dimension="lon")
+ xt = MercatorTicker(dimension="lon") + xt = MercatorTicker(dimension="lon")
+ xt.num_minor_ticks = _get_num_minor_ticks(LinearAxis, opts.x_minor_ticks) + xt.num_minor_ticks = _get_num_minor_ticks(LinearAxis, opts.x_minor_ticks)
+ self.add_layout(LinearAxis(formatter=xf, ticker=xt, axis_label=opts.x_axis_label), opts.x_axis_location) + self.add_layout(LinearAxis(formatter=xf, ticker=xt, axis_label=opts.x_axis_label), opts.x_axis_location)
+
- yf = MercatorTickFormatter(dimension="lat")
- yt = MercatorTicker(dimension="lat")
- self.add_layout(LinearAxis(formatter=yf, ticker=yt), 'left')
+ if opts.y_axis_location is not None: + if opts.y_axis_location is not None:
+ yf = MercatorTickFormatter(dimension="lat") + yf = MercatorTickFormatter(dimension="lat")
+ yt = MercatorTicker(dimension="lat") + yt = MercatorTicker(dimension="lat")
@ -391,8 +279,8 @@ index 283d018ae97..2073a456a86 100644
- tool_objs, tool_map = process_tools_arg(self, opts.tools) - tool_objs, tool_map = process_tools_arg(self, opts.tools)
+ tool_objs, tool_map = process_tools_arg(self, opts.tools, opts.tooltips) + tool_objs, tool_map = process_tools_arg(self, opts.tools, opts.tooltips)
self.add_tools(*tool_objs) self.add_tools(*tool_objs)
- process_active_tools(self.toolbar, tool_map, - process_active_tools(self.toolbar, tool_map, opts.active_drag, opts.active_inspect, opts.active_scroll, opts.active_tap)
- opts.active_drag, opts.active_inspect, opts.active_scroll, opts.active_tap, opts.active_multi) -
+ process_active_tools( + process_active_tools(
+ self.toolbar, + self.toolbar,
+ tool_map, + tool_map,
@ -405,7 +293,7 @@ index 283d018ae97..2073a456a86 100644
annular_wedge = Figure.annular_wedge annular_wedge = Figure.annular_wedge
@@ -245,51 +239,8 @@ def gmap(google_api_key, map_options, **kwargs): @@ -242,51 +249,8 @@ def gmap(google_api_key, map_options, **
# Dev API # Dev API
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@ -459,3 +347,40 @@ index 283d018ae97..2073a456a86 100644
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Private API # Private API
Index: bokeh-2.3.3/bokeh/server/static/js/lib/models/tools/toolbar.js
===================================================================
--- bokeh-2.3.3.orig/bokeh/server/static/js/lib/models/tools/toolbar.js
+++ bokeh-2.3.3/bokeh/server/static/js/lib/models/tools/toolbar.js
@@ -9,7 +9,7 @@ export const Drag = Tool;
export const Inspection = Tool;
export const Scroll = Tool;
export const Tap = Tool;
-const _get_active_attr = (et) => {
+function _get_active_attr(et) {
switch (et) {
case 'tap': return 'active_tap';
case 'pan': return 'active_drag';
@@ -19,7 +19,7 @@ const _get_active_attr = (et) => {
}
return null;
};
-const _supports_auto = (et) => {
+function _supports_auto(et): boolean {
return et == 'tap' || et == 'pan';
};
export class Toolbar extends ToolbarBase {
@@ -28,12 +28,12 @@ export class Toolbar extends ToolbarBase
}
static init_Toolbar() {
this.prototype.default_view = ToolbarBaseView;
- this.define(({ Or, Ref, Auto, Null, Nullable }) => ({
+ this.define(({ Or, Ref, Auto, Null }) => ({
active_drag: [Or(Ref(Drag), Auto, Null), "auto"],
active_inspect: [Or(Ref(Inspection), Auto, Null), "auto"],
active_scroll: [Or(Ref(Scroll), Auto, Null), "auto"],
active_tap: [Or(Ref(Tap), Auto, Null), "auto"],
- active_multi: [Nullable(Ref(GestureTool)), null],
+ active_multi: [Or(Ref(GestureTool), Auto, Null), "auto"],
}));
}
connect_signals() {

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Jul 20 13:56:14 UTC 2021 - Ben Greiner <code@bnavigator.de>
- Remove URL for rebased patch
bokeh-pr11218-figure-toolbar-active-properties.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Jul 19 08:35:07 UTC 2021 - Ben Greiner <code@bnavigator.de> Mon Jul 19 08:35:07 UTC 2021 - Ben Greiner <code@bnavigator.de>