示例#1
0
    def test_with_float_bounds(self):
        r = bpp.get_range((1.2, 10))
        assert isinstance(r, Range1d)
        assert r.start == 1.2
        assert r.end == 10

        r = bpp.get_range([1.2, 10])
        assert isinstance(r, Range1d)
        assert r.start == 1.2
        assert r.end == 10
示例#2
0
 def test_with_string_seq(self):
     f = ["foo" ,"end", "baz"]
     for t in [list, tuple]:
         r = bpp.get_range(t(f))
         assert isinstance(r, FactorRange)
         # FactorRange accepts Seq, but get_range always sets a list copy
         assert r.factors == f
示例#3
0
 def test_with_pandas_group(self, pd) -> None:
     from bokeh.sampledata.iris import flowers
     g = flowers.groupby('species')
     r = bpp.get_range(g)
     assert isinstance(r, FactorRange)
     assert r.factors == ['setosa', 'versicolor',
                          'virginica']  # should always be sorted
示例#4
0
 def test_with_ndarray_factors(self):
     f = np.array(["Crosby", "Stills", "Nash", "Young"])
     r = bpp.get_range(f)
     assert isinstance(r, FactorRange)
     assert r.factors == list(f)
示例#5
0
 def test_with_too_long_ndarray(self):
     with pytest.raises(ValueError):
         bpp.get_range(np.array([10, 20, 30]))
示例#6
0
 def test_with_ndarray(self):
     r = bpp.get_range(np.array([10, 20]))
     assert isinstance(r, Range1d)
     assert r.start == 10
     assert r.end == 20
示例#7
0
 def test_with_Range(self):
     for t in [Range1d, DataRange1d, FactorRange]:
         rng = t()
         r = bpp.get_range(rng)
         assert r is rng
示例#8
0
 def test_with_None(self):
     r = bpp.get_range(None)
     assert isinstance(r, DataRange1d)
示例#9
0
 def test_with_too_long_series(self, pd):
     with pytest.raises(ValueError):
         bpp.get_range(pd.Series([20, 30, 40]))
示例#10
0
 def test_with_series(self, pd):
     r = bpp.get_range(pd.Series([20, 30]))
     assert isinstance(r, Range1d)
     assert r.start == 20
     assert r.end == 30