Skip to content

Commit

Permalink
Merge branch 'master' into second_y_axis
Browse files Browse the repository at this point in the history
  • Loading branch information
cphalpert authored Feb 16, 2019
2 parents 5ee27f8 + 9e5dd9e commit 95718e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 7 additions & 3 deletions chartify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 2 additions & 5 deletions chartify/_core/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions tests/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down

0 comments on commit 95718e4

Please sign in to comment.