-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix error when latest version 3.0.3 of bokeh is installed (#630)
* Fix error when latest version 3.0.3 of bokeh is installed * fix tests import * fix missing properties * reformatting graphs for plotting * Fix graph nodes attributes * Fix numbers and captions for nodes * Add bokeh 2.4.3 compatibility * Added documentation to figure_dimension * Fixed tests and use in-package imports * More formatting fixes * isort run * Formatting pydocstyle * formatting fixes * Fixing lint issues * Fixing mypy errors for Bokeh 3.0 Adding mypy to pre-commit Suppressing mypy annotation-unchecked in github action * Re-wrote parameter wrapper as decorator - tested with Bokeh v2 and v3 * Reverting accidentally modified conf.py * Updating bokeh reqs, bumping version to 2.3.2 --------- Co-authored-by: Claudiu Toma <ctoma@microsoft.com> Co-authored-by: Ian Hellen <ianhelle@microsoft.com>
- Loading branch information
1 parent
193cc74
commit 8d83f69
Showing
22 changed files
with
340 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
"""Version file.""" | ||
VERSION = "2.3.1" | ||
VERSION = "2.3.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# ------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# -------------------------------------------------------------------------- | ||
"""figure_dimension - helps set the width and height properties of a figure for plotting.""" | ||
from functools import wraps | ||
from typing import Any, Callable | ||
|
||
from bokeh.plotting import figure | ||
|
||
from .._version import VERSION | ||
from ..common.utility import export | ||
|
||
__version__ = VERSION | ||
__author__ = "Claudiu Toma" | ||
|
||
|
||
@export | ||
def set_figure_size(fig: figure, width: int, height: int) -> figure: | ||
"""Set the figure size. | ||
Args: | ||
fig (figure): initial figure | ||
width (int): width dimension | ||
height (int): height dimension | ||
Returns | ||
------- | ||
figure: figure with correct width and height | ||
""" | ||
if hasattr(figure(), "height"): | ||
setattr(fig, "height", height) | ||
if hasattr(figure(), "plot_height"): | ||
setattr(fig, "plot_height", height) | ||
if hasattr(figure(), "width"): | ||
setattr(fig, "width", width) | ||
if hasattr(figure(), "plot_width"): | ||
setattr(fig, "plot_width", width) | ||
return fig | ||
|
||
|
||
_BOKEH_3_FIG_PARAMS = { | ||
"plot_height": "height", | ||
"plot_width": "width", | ||
} | ||
_BOKEH_2_FIG_PARAMS = {val: key for key, val in _BOKEH_3_FIG_PARAMS.items()} | ||
|
||
|
||
def bokeh_figure(func) -> Callable[[Any], Any]: | ||
""" | ||
Wrap bokeh 'figure' function for version-agnostic param naming. | ||
Parameters | ||
---------- | ||
func : Callable | ||
The function to wrap | ||
Returns | ||
------- | ||
Callable : | ||
The wrapped figure function. | ||
""" | ||
|
||
@wraps(func) | ||
def set_figure_size_params(*args, **kwargs): | ||
"""Re-write parameters names for Bokeh version.""" | ||
if func == figure: | ||
param_mapper = ( | ||
_BOKEH_3_FIG_PARAMS | ||
if hasattr(func(), "height") | ||
else _BOKEH_2_FIG_PARAMS | ||
) | ||
|
||
func_kwargs = { | ||
param_mapper.get(param, param): value for param, value in kwargs.items() | ||
} | ||
return func(*args, **func_kwargs) | ||
return func(*args, **kwargs) | ||
|
||
return set_figure_size_params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.