Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Violin plots fail when called with empty array #343

Open
JS3xton opened this issue Oct 27, 2020 · 2 comments · Fixed by #348
Open

Violin plots fail when called with empty array #343

JS3xton opened this issue Oct 27, 2020 · 2 comments · Fixed by #348
Labels

Comments

@JS3xton
Copy link
Contributor

JS3xton commented Oct 27, 2020

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
StopIteration

The 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 = 1
@JS3xton
Copy link
Contributor Author

JS3xton commented Jan 26, 2021

Fixed in FlowCal v1.3.0.

@JS3xton JS3xton closed this as completed Jan 26, 2021
@JS3xton
Copy link
Contributor Author

JS3xton commented Mar 3, 2023

FlowCal.plot.violin(data=[]) still fails in v1.3.0 with the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jsexton/Downloads/FlowCal-master/FlowCal/plot.py", line 1810, in violin
    t = _LogicleTransform(data=data, channel=channel)
  File "/home/jsexton/Downloads/FlowCal-master/FlowCal/plot.py", line 315, in __init__
    raise ValueError("T should be positive")
ValueError: T should be positive

@JS3xton JS3xton reopened this Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant