[IPython-User] IPython notebook custom widgets fastest way to send a numpy array to javascript

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[IPython-User] IPython notebook custom widgets fastest way to send a numpy array to javascript

gabriele.lanaro
Hi!

I'm trying to use IPython traitlets system to send a NumPy array towards the JS side in an IPython notebook widget (it's a molecular viewer). The array I'm trying to send can be pretty big (like of shape (100000, 3)) as it's an array of 3d coordinates.

What I'm doing right now is:

setup a traitlet like:

class MolecularViewer:
    coordinates = Dict(sync=True)

Then I send the array as a base64 string and type info:

molecular_viewer.coordinates = {'type': dtype,
                                                     'shape', shape,
                                                     'data' : "b64stringrepresentation"}

and I decode back in JS to obtain a TypedArray. Unfortunately the decoding has become a bottleneck (it has to run at interactive speeds possibly).

Do you know a better way to pass large NumPy arrays to javascript (getting a TypedArray on the other side)?

Thank you,

Gabriele

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: IPython notebook custom widgets fastest way to send a numpy array to javascript

rossant
You could try the recently merged binary buffers that use WebSocket (see the PR on GitHub with the example notebook).


Le vendredi 24 octobre 2014, Gabriele Lanaro <[hidden email]> a écrit :
Hi!

I'm trying to use IPython traitlets system to send a NumPy array towards the JS side in an IPython notebook widget (it's a molecular viewer). The array I'm trying to send can be pretty big (like of shape (100000, 3)) as it's an array of 3d coordinates.

What I'm doing right now is:

setup a traitlet like:

class MolecularViewer:
    coordinates = Dict(sync=True)

Then I send the array as a base64 string and type info:

molecular_viewer.coordinates = {'type': dtype,
                                                     'shape', shape,
                                                     'data' : "b64stringrepresentation"}

and I decode back in JS to obtain a TypedArray. Unfortunately the decoding has become a bottleneck (it has to run at interactive speeds possibly).

Do you know a better way to pass large NumPy arrays to javascript (getting a TypedArray on the other side)?

Thank you,

Gabriele

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user