Closed scottgigante closed 4 years ago
Describe the bug scprep.plot.scatter2d doesn't handle a single point
scprep.plot.scatter2d
To Reproduce
import scprep scprep.plot.scatter2d([1, 2])
Expected behavior Should behave the same as
import scprep scprep.plot.scatter2d([[1, 2]])
Actual behavior
--------------------------------------------------------------------------- IndexError Traceback (most recent call last) ~/.local/lib/python3.8/site-packages/scprep/select.py in _get_column_length(data) 39 try: ---> 40 return data.shape[1] 41 except (IndexError, AttributeError): IndexError: tuple index out of range During handling of the above exception, another exception occurred: TypeError Traceback (most recent call last) <ipython-input-21-51af89786b54> in <module> ----> 1 scprep.plot.scatter2d([1, 2]) </usr/lib/python3.8/site-packages/decorator.py:decorator-gen-142> in scatter2d(data, c, cmap, cmap_scale, s, mask, discrete, ax, legend, colorbar, shuffle, figsize, ticks, xticks, yticks, ticklabels, xticklabels, yticklabels, label_prefix, xlabel, ylabel, title, fontsize, legend_title, legend_loc, legend_anchor, filename, dpi, **plot_kwargs) ~/.local/lib/python3.8/site-packages/scprep/utils.py in _with_pkg(fun, pkg, min_version, *args, **kwargs) 81 check_version(pkg, min_version=min_version) 82 __imported_pkgs.add((pkg, min_version)) ---> 83 return fun(*args, **kwargs) 84 85 ~/.local/lib/python3.8/site-packages/scprep/plot/scatter.py in scatter2d(data, c, cmap, cmap_scale, s, mask, discrete, ax, legend, colorbar, shuffle, figsize, ticks, xticks, yticks, ticklabels, xticklabels, yticklabels, label_prefix, xlabel, ylabel, title, fontsize, legend_title, legend_loc, legend_anchor, filename, dpi, **plot_kwargs) 943 data = utils.toarray(data) 944 return scatter( --> 945 x=select.select_cols(data, idx=0), 946 y=select.select_cols(data, idx=1), 947 c=c, ~/.local/lib/python3.8/site-packages/scprep/select.py in select_cols(data, idx, starts_with, ends_with, exact_word, regex, *extra_data) 441 idx = utils.toarray(idx) 442 data = data[:, idx] --> 443 if _get_column_length(data) == 0: 444 warnings.warn("Selecting 0 columns.", UserWarning) 445 elif isinstance(data, pd.DataFrame): ~/.local/lib/python3.8/site-packages/scprep/select.py in _get_column_length(data) 40 return data.shape[1] 41 except (IndexError, AttributeError): ---> 42 return len(data) 43 44 TypeError: object of type 'numpy.int64' has no len()
scprep version 1.0.4a0
Output of pd.show_versions()
pd.show_versions()
Describe the bug
scprep.plot.scatter2d
doesn't handle a single pointTo Reproduce
Expected behavior Should behave the same as
Actual behavior
scprep version 1.0.4a0
Output of
pd.show_versions()