diff --git a/chartify/__init__.py b/chartify/__init__.py index 89f882a..a58d14e 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'), hide_banner=True) set_display_settings() diff --git a/chartify/_core/plot.py b/chartify/_core/plot.py index cca1ffa..05e0196 100644 --- a/chartify/_core/plot.py +++ b/chartify/_core/plot.py @@ -37,11 +37,8 @@ def __init__(self, chart, y_range_name="default"): @staticmethod def _axis_format_precision(max_value, min_value): difference = abs(max_value - min_value) - if difference: - precision = abs(int(np.floor(np.log10(difference)))) + 1 - else: - precision = 1 - print(precision) + 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]",