From 4576343702fc31ba27f6462597c63c0ce937cf9c Mon Sep 17 00:00:00 2001 From: Joseph Fox-Rabinovitz Date: Sun, 7 Feb 2016 21:50:25 -0500 Subject: MAINT: Made `iterable` return a boolean --- numpy/lib/function_base.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'numpy') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 788807086..b8e017eab 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -56,24 +56,24 @@ def iterable(y): Returns ------- - b : {0, 1} - Return 1 if the object has an iterator method or is a sequence, - and 0 otherwise. + b : bool + Return ``True`` if the object has an iterator method or is a + sequence and ``False`` otherwise. Examples -------- >>> np.iterable([1, 2, 3]) - 1 + True >>> np.iterable(2) - 0 + False """ try: iter(y) - except: - return 0 - return 1 + except TypeError: + return False + return True def _hist_optim_numbins_estimator(a, estimator): -- cgit v1.2.1