From 5607e917bf7ca2744d2cfc621094618b2f2e34de Mon Sep 17 00:00:00 2001 From: Luke Canavan Date: Sun, 2 Dec 2018 17:33:27 -0600 Subject: [PATCH 1/3] Make 'import chartify' expr defer to previous call to 'bokeh.io.output_notebook' --- chartify/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/chartify/__init__.py b/chartify/__init__.py index 89f882a..e4532f1 100644 --- a/chartify/__init__.py +++ b/chartify/__init__.py @@ -32,14 +32,18 @@ def set_display_settings(): from ipykernel.zmqshell import ZMQInteractiveShell from bokeh.io import output_notebook from bokeh.resources import Resources + from bokeh.io.state import curstate ipython_instance = get_ipython() if ipython_instance is not None: if isinstance(ipython_instance, ZMQInteractiveShell): _IPYTHON_INSTANCE = True - # Inline resources uses bokeh.js from the local version. - # This enables offline usage. - output_notebook(Resources('inline')) + # Defer to previous call to ``output_notebook`` so that users + # can specify their own notebook type and Bokeh resources + if curstate().notebook_type is None: + # Inline resources uses bokeh.js from the local version. + # This enables offline usage. + output_notebook(Resources('inline')) set_display_settings() From 139126bd0b204f3605d73808904ffb51c5857b0f Mon Sep 17 00:00:00 2001 From: Luke Canavan Date: Sun, 2 Dec 2018 17:56:20 -0600 Subject: [PATCH 2/3] Hide the 'BokehJS x.y.z successfully loaded.' from 'import chartify' expr --- chartify/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chartify/__init__.py b/chartify/__init__.py index 89f882a..4ac60ad 100644 --- a/chartify/__init__.py +++ b/chartify/__init__.py @@ -39,7 +39,7 @@ def set_display_settings(): _IPYTHON_INSTANCE = True # Inline resources uses bokeh.js from the local version. # This enables offline usage. - output_notebook(Resources('inline')) + output_notebook(Resources('inline'), hide_banner=True) set_display_settings() From 0eb5f0a85bc65cc980c50c3f6b2d0a1f53bd32b1 Mon Sep 17 00:00:00 2001 From: x4base Date: Tue, 11 Dec 2018 11:58:45 +0800 Subject: [PATCH 3/3] Fix the axis precision when the max value equals to the min value --- chartify/_core/plot.py | 3 ++- tests/test_plots.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/chartify/_core/plot.py b/chartify/_core/plot.py index 0f0f136..b3809a7 100644 --- a/chartify/_core/plot.py +++ b/chartify/_core/plot.py @@ -36,7 +36,8 @@ def __init__(self, chart): @staticmethod def _axis_format_precision(max_value, min_value): difference = abs(max_value - min_value) - precision = abs(int(np.floor(np.log10(difference)))) + 1 + precision = abs(int(np.floor( + np.log10(difference if difference else 1)))) + 1 zeros = ''.join(['0']*precision) return "0,0.[{}]".format(zeros) diff --git a/tests/test_plots.py b/tests/test_plots.py index 63b3dec..b50b792 100644 --- a/tests/test_plots.py +++ b/tests/test_plots.py @@ -491,6 +491,7 @@ class TestAxisFormatPrecision: def setup(self): self.tests = { + (0, 0): "0,0.[0]", (0, 0.004): "0,0.[0000]", (0, 0.04): "0,0.[000]", (0, 0.4): "0,0.[00]",