diff options
author | Nathaniel J. Smith <njs@pobox.com> | 2016-02-11 21:25:04 +0000 |
---|---|---|
committer | Nathaniel J. Smith <njs@pobox.com> | 2016-02-11 21:25:04 +0000 |
commit | 47b6c2b8bacb510cac62d490c159ec116080d1d0 (patch) | |
tree | b3a2a8bc7698942de05b735060d514afac7c1c6e /numpy/lib | |
parent | 920c527ab54b5e9097e0504ddae8d9b2b80a288c (diff) | |
parent | 4576343702fc31ba27f6462597c63c0ce937cf9c (diff) | |
download | numpy-47b6c2b8bacb510cac62d490c159ec116080d1d0.tar.gz |
Merge pull request #7202 from madphysicist/iterable-bool-return
MAINT: Made `iterable` return a boolean
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/function_base.py | 16 |
1 files changed, 8 insertions, 8 deletions
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): |