Skip to content

Comments

fix broken plotting functions and update for Bokeh 3.x#198

Draft
PrasannaPal21 wants to merge 6 commits intoioos:mainfrom
PrasannaPal21:fix/plotting-bugs
Draft

fix broken plotting functions and update for Bokeh 3.x#198
PrasannaPal21 wants to merge 6 commits intoioos:mainfrom
PrasannaPal21:fix/plotting-bugs

Conversation

@PrasannaPal21
Copy link
Contributor

bokeh_multi_var() was calling bokeh_plot_var() with 7 args but bokeh_plot_var() only accepted 6 — added the missing var_name parameter. Also added time to bokeh_plot() since it was missing.

Other fixes in plotting.py:
circle() → scatter() (deprecated in Bokeh 3.4)
removed plot_width/plot_height from gridplot() kwargs (removed in Bokeh 3.x)

NumpyStream.data() didn't take a stream_id, so plotting with NumpyStream would crash. Added optional stream_id support.

@PrasannaPal21
Copy link
Contributor Author

var_name is not being used, but it was originally there so I didnt remove it.

bokeh_plot() and bokeh_multi_var() were already passing var_name but bokeh_plot_var() didn't have it in its signature, that's what caused the crash

Comment on lines 118 to 128
"plot_width": 600,
"plot_height": 200,
"ncols": 2,
**kwargs,
}

if "plot_width" in kwargs:
kwargs.pop("plot_width")
if "plot_height" in kwargs:
kwargs.pop("plot_height")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain these changes with your own words, not AI, and what problem are you trying to solve here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plot_width and plot_height were deprecated in bokeh 2.4.0 and were completely removed in 3.0.0. so it was causing the unexpected keyword argument error when we use the arbitrary **kwargs into the plotting function.
kwargs is a dictionary, so before we call gridplot, removing(popping) these( plot_width and plot_height ), if present, we prevent the crashes.
these were replaced by width and height in the later version of bokeh.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, why not update the kw here? Poping them hides the wrong syntax. It smells of an AI solution that just tries to solve the error rather than understand the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly just googled and saw that those were completely removed so my first thought was just to quickly pop them out of the kwargs so that gridplot would not crash.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I remap it kwarg["width"] = kwarg.pop("plot_width")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why hide them or renamed them when they were removed upstream? What is the best course of action for something that was remove? A clean API or some code magic that hides it?

Comment on lines 209 to 211
def data(self, stream_id=None):
if stream_id is not None and isinstance(self.inp, dict) and stream_id in self.inp:
return self.inp[stream_id]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain these changes and the jump in cyclomatic complexity here? Can this be simpler?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous data() method was returning the entire self.inp object. but if the inp was a dictionary with multiple variables, it would return whole dictionary instead of the specific variables which we requested. this was causing bokeh to crash when plotting.
I modified it so that if a dictionary is provided we return only the requested variable's data.

I am not getting the cyclomatic complexity thing, I'll study this and then try to find out if there is a better way to do this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cyclomatic complexity

Before it only returned the input. Anything downstream could filter this input that what they need. Now you add a new variable, check its value, check the input type, and check if the new variable is a key in the input. That is the extra complexity added.

Tip: How is this function used? What can be done in the use case to reduce that complexity?

@PrasannaPal21
Copy link
Contributor Author

hey @ocefpaf
As you Suggested I shifted the stream parsing from streams.py to where it was actually being used(plotting.py). and mapped the kwargs correctly.
I learned seperation of concerns and cyclomatic complexity today 🙌

please take a look and guide if I am missing again something.

@ocefpaf ocefpaf marked this pull request as draft February 20, 2026 18:52
@PrasannaPal21
Copy link
Contributor Author

PrasannaPal21 commented Feb 22, 2026

Sorry for the delay in response. Understood that if those are deprecated by bokeh itself we dont have to take of them.

currently reviewing the tests before requesting the review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants