-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1010 from ioam/functick_fix
Fixed bokeh FuncTickFormater
- Loading branch information
Showing
4 changed files
with
77 additions
and
14 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,42 @@ | ||
from unittest import SkipTest | ||
|
||
from holoviews.core.options import Store | ||
from holoviews.element.comparison import ComparisonTestCase | ||
|
||
try: | ||
from holoviews.plotting.bokeh import util | ||
bokeh_renderer = Store.renderers['bokeh'] | ||
except: | ||
bokeh_renderer = None | ||
|
||
|
||
class TestBokehUtils(ComparisonTestCase): | ||
|
||
def setUp(self): | ||
if not bokeh_renderer: | ||
raise SkipTest("Bokeh required to test bokeh plot utils.") | ||
|
||
|
||
def test_py2js_funcformatter_single_arg(self): | ||
def test(x): return '%s$' % x | ||
jsfunc = util.py2js_tickformatter(test) | ||
js_func = ('var x = tick;\nvar formatter;\nformatter = function () {\n' | ||
' return "" + x + "$";\n};\n\nreturn formatter();\n') | ||
self.assertEqual(jsfunc, js_func) | ||
|
||
|
||
def test_py2js_funcformatter_two_args(self): | ||
def test(x, pos): return '%s$' % x | ||
jsfunc = util.py2js_tickformatter(test) | ||
js_func = ('var x = tick;\nvar formatter;\nformatter = function () {\n' | ||
' return "" + x + "$";\n};\n\nreturn formatter();\n') | ||
self.assertEqual(jsfunc, js_func) | ||
|
||
|
||
def test_py2js_funcformatter_arg_and_kwarg(self): | ||
def test(x, pos=None): return '%s$' % x | ||
jsfunc = util.py2js_tickformatter(test) | ||
js_func = ('var x = tick;\nvar formatter;\nformatter = function () {\n' | ||
' pos = (pos === undefined) ? null: pos;\n return "" ' | ||
'+ x + "$";\n};\n\nreturn formatter();\n') | ||
self.assertEqual(jsfunc, js_func) |