Skip to content

Commit

Permalink
Made change to jupyter notebooks automatic, deleted jupyter argument
Browse files Browse the repository at this point in the history
  • Loading branch information
lej0hn committed Jul 10, 2024
1 parent d9c3284 commit 37deda4
Showing 1 changed file with 9 additions and 33 deletions.
42 changes: 9 additions & 33 deletions pyneuroml/plot/PlotMorphologyVispy.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ def plot_interactive_3D(
highlight_spec: typing.Optional[typing.Dict[typing.Any, typing.Any]] = None,
precision: typing.Tuple[int, int] = (4, 200),
upright: bool = False,
jupyter: bool = False,
):
"""Plot interactive plots in 3D using Vispy
Expand Down Expand Up @@ -435,8 +434,6 @@ def plot_interactive_3D(
"upwards" instead of "downwards" in most cases. Note that the original cell object
is unchanged, this is for visualization purposes only.
:type upright: bool
:param jupyter: Set to True to run visualizations in jupyter notebooks. Default is False
:type jupyter: bool
:throws ValueError: if `plot_type` is not one of "detailed", "constant",
"schematic", or "point"
Expand All @@ -454,13 +451,9 @@ def plot_interactive_3D(
if verbose:
logger.info(f"Visualising {nml_file}")

if not jupyter:
from IPython import get_ipython

ipython = get_ipython()
# Check if the IPython instance is using the kernel environment
if ipython and "IPKernelApp" in ipython.config:
logging.warning("Kernel detected. Try setting jupyter=True")
jupyter = False
if app.Application.is_interactive(app):
jupyter = True

# if it's a file, load it first
if isinstance(nml_file, str):
Expand Down Expand Up @@ -706,7 +699,6 @@ def plot_interactive_3D(
meshdata=meshdata,
mesh_precision=precision[0],
upright=upright,
jupyter=jupyter,
)
elif (
plot_type == "detailed"
Expand Down Expand Up @@ -736,7 +728,6 @@ def plot_interactive_3D(
mesh_precision=precision[0],
highlight_spec=cell_highlight_spec,
upright=upright,
jupyter=jupyter,
)

# if too many meshes, reduce precision and retry, recursively
Expand All @@ -759,7 +750,6 @@ def plot_interactive_3D(
precision=precision,
highlight_spec=highlight_spec,
upright=upright,
jupyter=jupyter,
)
# break the recursion, don't plot in the calling method
return
Expand Down Expand Up @@ -857,7 +847,6 @@ def plot_3D_cell_morphology(
mesh_precision: int = 2,
highlight_spec: typing.Optional[typing.Dict[typing.Any, typing.Any]] = None,
upright: bool = False,
jupyter: bool = False,
):
"""Plot the detailed 3D morphology of a cell using vispy.
https://vispy.org/
Expand Down Expand Up @@ -958,8 +947,6 @@ def plot_3D_cell_morphology(
"upwards" instead of "downwards" in most cases. Note that the original cell object
is unchanged, this is for visualization purposes only.
:type upright: bool
:param jupyter: Set to True to run visualizations in jupyter notebooks. Default is False
:type jupyter: bool
:raises: ValueError if `cell` is None
"""
Expand All @@ -972,13 +959,9 @@ def plot_3D_cell_morphology(
highlight_spec = {}
logging.debug("highlight_spec is " + str(highlight_spec))

if not jupyter:
from IPython import get_ipython

ipython = get_ipython()
# Check if the IPython instance is using the kernel environment
if ipython and "IPKernelApp" in ipython.config:
logging.warning("Kernel detected. Try setting jupyter=True")
jupyter = False
if app.Application.is_interactive(app):
jupyter = True

view_center = None
if upright:
Expand Down Expand Up @@ -1257,7 +1240,6 @@ def plot_3D_schematic(
meshdata: typing.Optional[typing.Dict[typing.Any, typing.Any]] = None,
mesh_precision: int = 2,
upright: bool = False,
jupyter: bool = False,
) -> None:
"""Plot a 3D schematic of the provided segment groups using vispy.
layer..
Expand Down Expand Up @@ -1330,19 +1312,13 @@ def plot_3D_schematic(
"upwards" instead of "downwards" in most cases. Note that the original cell object
is unchanged, this is for visualization purposes only.
:type upright: bool
:param jupyter: Set to True to run visualizations in jupyter notebooks. Default is False
:type jupyter: bool
"""
if title == "":
title = f"3D schematic of segment groups from {cell.id}"

if not jupyter:
from IPython import get_ipython

ipython = get_ipython()
# Check if the IPython instance is using the kernel environment
if ipython and "IPKernelApp" in ipython.config:
logging.warning("Kernel detected. Try setting jupyter=True")
jupyter = False
if app.Application.is_interactive(app):
jupyter = True

view_center = None
if upright:
Expand Down

0 comments on commit 37deda4

Please sign in to comment.