bokeh.core.query.find

Here are the examples of the python api bokeh.core.query.find taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

7 Examples 7

3 Source : test_query.py
with MIT License
from rthorst

def test_type():

    for typ, count in typcases.items():
        res = list(q.find(plot.references(), dict(type=typ)))
        assert len(res) == count
        assert all(isinstance(x, typ) for x in res)

def test_tags_with_scalar():

3 Source : test_query.py
with MIT License
from rthorst

def test_tags_with_scalar():
    cases = {
        11: 1,
        12: 0,
    }

    for tag, count in cases.items():
        res = list(q.find(plot.references(), dict(tags=tag)))
        assert len(res) == count

def test_tags_with_string():

3 Source : test_query.py
with MIT License
from rthorst

def test_tags_with_string():
    cases = {
        "foo": 2,
        "bar": 1,
    }

    for tag, count in cases.items():
        res = list(q.find(plot.references(), dict(tags=tag)))
        assert len(res) == count

def test_tags_with_seq():

3 Source : test_query.py
with MIT License
from rthorst

def test_tags_with_seq():
    cases = {
        "foo": 2,
        "bar": 1,
    }

    for tag, count in cases.items():
        res = list(q.find(plot.references(), dict(tags=[tag])))
        assert len(res) == count

    res = list(q.find(plot.references(), dict(tags=list(cases.keys()))))
    assert len(res) == 2

def test_name():

3 Source : test_query.py
with MIT License
from rthorst

def test_name():
    cases = {
        "myline": Line,
        "mycircle": Circle,
        "myrect": Rect,
    }

    for name, typ in cases.items():
        res = list(q.find(plot.references(), dict(name=name)))
        assert len(res) == 1
        assert all(isinstance(x.glyph, typ) for x in res)

def test_in():

3 Source : test_query.py
with MIT License
from rthorst

def test_conjuction():
    res = list(
        q.find(plot.references(), dict(type=Axis, tags="foo"))
    )
    assert len(res) == 0

    res = list(
        q.find(plot.references(), dict(type=Range1d, tags="foo"))
    )
    assert len(res) == 2

    res = list(
        q.find(plot.references(), dict(type=GlyphRenderer, name="mycircle"))
    )
    assert len(res) == 1

def test_ops():

3 Source : test_query.py
with MIT License
from rthorst

def test_with_context():
    res = list(
        q.find(plot.references(), {'layout': 'below'}, {'plot': plot})
    )
    assert len(res) == 1

    res = list(
        q.find(plot.references(), {'select': 'below'}, {'plot': plot})
    )
    assert len(res) == 0

#-----------------------------------------------------------------------------
# Private API
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------