diff options
author | Lars Buitinck <L.J.Buitinck@uva.nl> | 2011-07-19 11:16:29 +0200 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-07-19 07:57:10 -0600 |
commit | a468b2e7ec180f9fb742070e1d108a8d56bdd0ea (patch) | |
tree | 69a9fe94a51ccb778bdc9879b70bba7fe9b6b4d5 /numpy/lib/function_base.py | |
parent | 64fce7c67849f44492d55ccf8a745b252bf1368b (diff) | |
download | numpy-a468b2e7ec180f9fb742070e1d108a8d56bdd0ea.tar.gz |
BUG: fix asarray_chkfinite to take dtype and order args, as advertised
Includes a doctest for dtype.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 3372f8aea..d20304a1b 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -524,7 +524,7 @@ def average(a, axis=None, weights=None, returned=False): else: return avg -def asarray_chkfinite(a): +def asarray_chkfinite(a, dtype=None, order=None): """ Convert the input to an array, checking for NaNs or Infs. @@ -570,8 +570,8 @@ def asarray_chkfinite(a): ``asarray_chkfinite`` is identical to ``asarray``. >>> a = [1, 2] - >>> np.asarray_chkfinite(a) - array([1, 2]) + >>> np.asarray_chkfinite(a, dtype=float) + array([1., 2.]) Raises ValueError if array_like contains Nans or Infs. @@ -584,7 +584,7 @@ def asarray_chkfinite(a): ValueError """ - a = asarray(a) + a = asarray(a, dtype=dtype, order=order) if (a.dtype.char in typecodes['AllFloat']) \ and (_nx.isnan(a).any() or _nx.isinf(a).any()): raise ValueError( |