Skip to content

Commit

Permalink
Improved option checking per suggestion from @flying-sheep
Browse files Browse the repository at this point in the history
  • Loading branch information
jorvis committed Feb 8, 2018
1 parent 6bc5a70 commit 86a3d79
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions scanpy/preprocessing/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,11 @@ def filter_genes(data, min_cells=None, min_counts=None, max_counts=None,
See :func:`~scanpy.api.pp.filter_cells`.
"""
multi_option_error = False

if min_cells is not None:
if min_counts is not None or max_cells is not None or max_counts is not None:
multi_option_error = True
if min_counts is not None:
if min_cells is not None or max_cells is not None or max_counts is not None:
multi_option_error = True
if max_cells is not None:
if min_cells is not None or min_counts is not None or max_counts is not None:
multi_option_error = True
if max_counts is not None:
if min_cells is not None or min_counts is not None or max_cells is not None:
multi_option_error = True
if multi_option_error:
raise ValueError("Only provide one of the optional arguments (`min_counts`," +
n_given_options = sum(option is not None for option in [min_cells, min_counts, max_cells, max_counts])
if n_given_options != 1:
raise ValueError("Only provide one of the optional arguments (`min_counts`," +
"`min_cells`, `max_counts`, `max_cells`) per call.")

if isinstance(data, AnnData):
adata = data.copy() if copy else data
gene_subset, number = filter_genes(adata.X, min_cells=min_cells,
Expand Down

0 comments on commit 86a3d79

Please sign in to comment.