Skip to content

Commit

Permalink
Make notebooks work with bokeh>=3 and remove bokeh<3 pin (#3061)
Browse files Browse the repository at this point in the history
* Register `h.Vector` serialization function with Bokeh in notebooks
* Unpin `bokeh<3` in documentation requirements and remove from main requirements
* Unpin `numpy<2` in documentation requirements
* Move serializer registration to `__init__.py`
  • Loading branch information
kbvw authored Oct 2, 2024
1 parent a2b8b35 commit 5b49b24
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 2 additions & 3 deletions docs/docs_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ jupyter
nbconvert
myst_parser
matplotlib
# bokeh 3 seems to break docs notebooks
bokeh<3
bokeh
# do not check import of next line
ipython
plotnine
numpy<2
numpy
plotly
nbsphinx
jinja2
Expand Down
2 changes: 0 additions & 2 deletions nrn_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ setuptools_scm
setuptools<=70.3.0
scikit-build
matplotlib
# bokeh 3 seems to break docs notebooks
bokeh<3
ipython
cython
packaging
Expand Down
10 changes: 10 additions & 0 deletions share/lib/python/neuron/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,3 +1835,13 @@ def _mview_html_tree(hlist, inside_mechanisms_in_use=0):
if _get_ipython() is not None:
html_formatter = _get_ipython().display_formatter.formatters["text/html"]
html_formatter.for_type(hoc.HocObject, _hocobj_html)

# in case Bokeh is installed, register a serialization function for hoc.Vector
try:
from bokeh.core.serialization import Serializer

Serializer.register(
h.Vector, lambda obj, serializer: [serializer.encode(item) for item in obj]
)
except ImportError:
pass

0 comments on commit 5b49b24

Please sign in to comment.