-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compare and Swap Holoviews Extension (#733)
* initial fix for comparing and swaping hv enviroment * add docstring and check for supported backends * pre-commit * refactor * update docstring * update comments and docstring * add to internal API --------- Co-authored-by: Orhan Eroglu <32553057+erogluorhan@users.noreply.github.com>
- Loading branch information
1 parent
545a18d
commit b417ac8
Showing
4 changed files
with
47 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import holoviews as hv | ||
|
||
|
||
class HoloviewsBackend: | ||
"""Utility class to compare and set a HoloViews plotting backend for | ||
visualization.""" | ||
|
||
def __init__(self): | ||
self.backend = None | ||
|
||
def assign(self, backend: str): | ||
"""Assigns a backend for use with HoloViews visualization. | ||
Parameters | ||
---------- | ||
backend : str | ||
Plotting backend to use, one of 'matplotlib', 'bokeh' | ||
""" | ||
|
||
if backend not in ["bokeh", "matplotlib"]: | ||
raise ValueError( | ||
f"Unsupported backend. Expected one of ['bokeh', 'matplotlib'], but received {backend}" | ||
) | ||
|
||
if backend != self.backend: | ||
# only call hv.extension if it needs to be changed | ||
hv.extension(backend) | ||
self.backend = backend | ||
|
||
|
||
# global reference to holoviews backend utility class | ||
backend = HoloviewsBackend() |