-
Notifications
You must be signed in to change notification settings - Fork 24
Violin plots fail when called with empty array #343
Copy link
Copy link
Open
Labels
Description
The following code fails using commit bc98686 (a few commits upstream of when plot-violin was merged into develop):
>>> FlowCal.plot.violin(data=[])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\sexto\.conda\envs\py3_anaconda2020.07_fc_JS3xton_bc98686\lib\site-packages\flowcal-1.2.2-py3.8.egg\FlowCal\plot.py", line 1690, in violin
StopIterationThe error occurs when next() is called on an empty iterator when trying to understand data:
# understand `data`
if channel is None:
# assume 1D sequence or sequence of 1D sequences
try:
first_element = next(iter(data)) # <-- fails here
except TypeError:
msg = "`data` should be 1D array or list of 1D arrays."
msg += " Specify `channel` to use ND array or list of ND"
msg += " arrays."
raise TypeError(msg)
# promote singleton if necessary
try:
iter(first_element) # success => sequence of 1D sequences
data_length = len(data)
except TypeError:
data = [data]
data_length = 1Reactions are currently unavailable