I was trying to implement a python module that would add a Datashading callback inspired on the DataShader Case Study in Python.
The callback function update_ds_image
calls gen_ds_image
which accesses iris_target_df
. No issues with this as iris_target_df
is in the notebooks scope.
My issue is if I have a class that has a data frame as an attribute (self._df
). Iām not able to use that data frame inside the callback function because it needs to have the callback signature similar to update_ds_image(layout, x_range, y_range, plot_width, plot_height)
.
I need to pass layout and Iām not able to pass self and access the data frame.
Is there any way I can access objects out of the layout scope (and not in the global scope) from an on_change
callback?
The only way I can make this work is adding the data frame reference to the module scope with globals()['df'] = self._df