Skip to content

Commit

Permalink
Merge pull request #42 from BlueBrain/fix-ions
Browse files Browse the repository at this point in the history
edge case where ions.data is an empty array
  • Loading branch information
AurelienJaquier authored Jul 16, 2024
2 parents 6d288a6 + c3dcade commit b24c9ed
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions currentscape/currentscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ def create_figure(voltage, currs, c, ions):
# put into classes
if c["current"]["autoscale_ticks_and_ylim"]:
autoscale_ticks_and_ylim(c, currs.pos_sum, currs.neg_sum)
if ions.data is not None and c["ions"]["autoscale_ticks_and_ylim"]:
if (
ions.data is not None
and ions.data.size
and c["ions"]["autoscale_ticks_and_ylim"]
):
autoscale_ticks_and_ylim(c, np.max(ions.data), abs(np.min(ions.data)), "ions")

rows_tot = get_rows_tot(c, ions)
Expand Down Expand Up @@ -118,7 +122,7 @@ def create_figure(voltage, currs, c, ions):
row += 1

# PLOT IONIC CONCENTRATIONS
if ions.data is not None:
if ions.data is not None and ions.data.size:
if use_patterns:
ions.plot_with_linestyles(c, row, rows_tot, cmap)
else:
Expand Down
2 changes: 1 addition & 1 deletion currentscape/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def get_rows_tot(c, ions):
rows_tot += 1
if c["show"]["all_currents"]:
rows_tot += 2
if ions.data is not None:
if ions.data is not None and ions.data.size:
rows_tot += 1
if c["show"]["total_contribution"]:
rows_tot += 2
Expand Down
4 changes: 4 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
autosummary_generate = True
autodoc_default_options = {"members": True, "show-inheritance": True}

suppress_warnings = [
'autosummary.import_cycle',
]


# -- Options for HTML output -------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion tests/test_currentscape_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_get_rows_tot():
assert rows == 10

config["show"]["total_contribution"] = False
ions.data = [[1, 2], [3, 4]]
ions.data = np.asarray([[1, 2], [3, 4]])
rows = get_rows_tot(config, ions)
assert rows == 9

Expand Down

0 comments on commit b24c9ed

Please sign in to comment.