1 2
from __future__ import absolute_import, division, unicode_literals
2

3 2
import sys
4

5 2
from distutils.version import LooseVersion
6

7 2
import numpy as np
8 2
import pytest
9

10 2
try:
11 2
    import holoviews as hv
12 2
    hv_version = LooseVersion(hv.__version__)
13 0
except Exception:
14 0
    hv, hv_version = None, None
15 2
hv_available = pytest.mark.skipif(hv is None or hv_version < '1.13.0a23', reason="requires holoviews")
16

17 2
try:
18 2
    import matplotlib as mpl
19 2
    mpl.use('Agg')
20 0
except Exception:
21 0
    mpl = None
22 2
mpl_available = pytest.mark.skipif(mpl is None, reason="requires matplotlib")
23

24 2
try:
25 2
    import pandas as pd
26 0
except Exception:
27 0
    pd = None
28 2
pd_available = pytest.mark.skipif(pd is None, reason="requires pandas")
29

30 2
try:
31 2
    import streamz
32 0
except Exception:
33 0
    streamz = None
34 2
streamz_available = pytest.mark.skipif(streamz is None, reason="requires streamz")
35

36 2
try:
37 2
    import jupyter_bokeh
38 0
except Exception:
39 0
    jupyter_bokeh = None
40 2
jb_available = pytest.mark.skipif(jupyter_bokeh is None, reason="requires jupyter_bokeh")
41

42 2
py3_only = pytest.mark.skipif(sys.version_info.major < 3, reason="requires Python 3")
43

44

45 2
def mpl_figure():
46 2
    import matplotlib.pyplot as plt
47 2
    fig = plt.figure()
48 2
    ax = fig.add_subplot(111)
49 2
    ax.plot(np.random.rand(10, 2))
50 2
    plt.close(fig)
51 2
    return fig
52

53

54 2
def check_layoutable_properties(layoutable, model):
55 2
    layoutable.background = '#ffffff'
56 2
    assert model.background == '#ffffff'
57

58 2
    layoutable.css_classes = ['custom_class']
59 2
    assert model.css_classes == ['custom_class']
60

61 2
    layoutable.width = 500
62 2
    assert model.width == 500
63

64 2
    layoutable.height = 450
65 2
    assert model.height == 450
66

67 2
    layoutable.min_height = 300
68 2
    assert model.min_height == 300
69

70 2
    layoutable.min_width = 250
71 2
    assert model.min_width == 250
72

73 2
    layoutable.max_height = 600
74 2
    assert model.max_height == 600
75

76 2
    layoutable.max_width = 550
77 2
    assert model.max_width == 550
78

79 2
    layoutable.margin = 10
80 2
    assert model.margin == (10, 10, 10, 10)
81

82 2
    layoutable.sizing_mode = 'stretch_width'
83 2
    assert model.sizing_mode == 'stretch_width'
84

85 2
    layoutable.width_policy = 'max'
86 2
    assert model.width_policy == 'max'
87

88 2
    layoutable.height_policy = 'min'
89 2
    assert model.height_policy == 'min'

Read our documentation on viewing source code .

Loading