Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 5
0
 def test_with_too_long_ndarray(self):
     with pytest.raises(ValueError):
         bpp.get_range(np.array([10, 20, 30]))
Exemplo n.º 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
Exemplo n.º 7
0
 def test_with_Range(self):
     for t in [Range1d, DataRange1d, FactorRange]:
         rng = t()
         r = bpp.get_range(rng)
         assert r is rng
Exemplo n.º 8
0
 def test_with_None(self):
     r = bpp.get_range(None)
     assert isinstance(r, DataRange1d)
Exemplo n.º 9
0
 def test_with_too_long_series(self, pd):
     with pytest.raises(ValueError):
         bpp.get_range(pd.Series([20, 30, 40]))
Exemplo n.º 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