From 53de3fbe36b2d0f5a68e191b619b4e935022cb46 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Wed, 13 Sep 2023 13:43:03 +0100 Subject: [PATCH] fix(vispy-morph): get title from cell object if no network is found Otherwise this throws an error and the tool crashes --- pyneuroml/plot/PlotMorphologyVispy.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pyneuroml/plot/PlotMorphologyVispy.py b/pyneuroml/plot/PlotMorphologyVispy.py index 119415cca..0278bd7d6 100644 --- a/pyneuroml/plot/PlotMorphologyVispy.py +++ b/pyneuroml/plot/PlotMorphologyVispy.py @@ -225,7 +225,8 @@ def create_new_vispy_canvas( console_widget.write(f"Center: {view.camera.center}") console_widget.write(console_text) console_widget.write( - f"Current camera: {view.camera.name}: " + cam_text[view.camera].replace("\n", " ").strip() + f"Current camera: {view.camera.name}: " + + cam_text[view.camera].replace("\n", " ").strip() ) if axes_pos: @@ -280,7 +281,8 @@ def vispy_on_key_press(event): # console_widget.write(f"Center: {view.camera.center}") console_widget.write(console_text) console_widget.write( - f"Current camera: {view.camera.name}: " + cam_text[view.camera].replace("\n", " ").strip() + f"Current camera: {view.camera.name}: " + + cam_text[view.camera].replace("\n", " ").strip() ) return scene, view @@ -348,7 +350,9 @@ def plot_interactive_3D( elif isinstance(nml_file, NeuroMLDocument): nml_model = nml_file else: - raise TypeError("Passed model is not a NeuroML file path, nor a neuroml.Cell, nor a neuroml.NeuroMLDocument") + raise TypeError( + "Passed model is not a NeuroML file path, nor a neuroml.Cell, nor a neuroml.NeuroMLDocument" + ) ( cell_id_vs_cell, @@ -368,7 +372,10 @@ def plot_interactive_3D( marker_colors = [] if title is None: - title = f"{nml_model.networks[0].id} from {nml_file}" + try: + title = f"{nml_model.networks[0].id} from {nml_file}" + except IndexError: + title = f"{nml_model.cells[0].id} from {nml_file}" logger.debug(f"positions: {positions}") logger.debug(f"pop_id_vs_cell: {pop_id_vs_cell}")