Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend patching to sub-items #6285

bryevdv opened this issue May 15, 2017 · 0 comments · Fixed by #6313

Extend patching to sub-items #6285

bryevdv opened this issue May 15, 2017 · 0 comments · Fixed by #6313


Copy link

bryevdv commented May 15, 2017

Given the following CDS:

    "foo" : [ 1,    2,    3,    4,    5    ],
    "bar" : [ 1.7,  3.2,  5.8,  9.7,  10.4 ],
    'baz" : [ img1, img2, img3, img4, img5 ],

where img1, etc. are 2d NumPy arrays, it is currently possible to patch individual elements using the existing patch format:

patches = {
    'foo' : [ (0, 1) ],
    'bar' : [ (0, -2), (1, 201) ],
    'baz': [ (0, img) ],


This suffers from two drawbacks:

  • The indexing scheme does not extend inside 2d images, it is only possible to patch entire images at a time.

  • Even for the 1d case, the indexing scheme is somewhat cumbersome in cases where it is desired to patch contiguous regions of a column.

Propose to extend the patching syntax to accept slices, and to provide a simple mechanism for generating slices:

# patch the first three elements of a 1d column
p1 = patcher[0:3]
patches = { 'foo': (p1, [1, 2, 3] } 

# patch the entire second column of a the 10th image
p2 = patcher[10, :, 2]
patches = { 'baz' : (p2, [...] }

Note: use of an object like patcher with a custom __getitem__ seems necessary, as slice syntax is only available inside indexing brackets.

Would serialize slices slice(1, 10, None) as (1, 10, null). Bounds and consistency checking could occur on the python side, but handling of the slice would occur in BokehJS in the CDS patch method:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging a pull request may close this issue.

1 participant