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