summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2007-08-01 23:48:41 +0000
committerStefan van der Walt <stefan@sun.ac.za>2007-08-01 23:48:41 +0000
commitb6406a5cf255bc49891d893d155af6d106b015a8 (patch)
treedd34618d056dae341f92a23877e7f3f33fb75ffe
parentcde89143c3818f245d2f8ca7b5ba4af4592e337b (diff)
downloadnumpy-b6406a5cf255bc49891d893d155af6d106b015a8.tar.gz
Fix asfarray to return an array instead of a matrix.
-rw-r--r--numpy/lib/tests/test_type_check.py6
-rw-r--r--numpy/lib/type_check.py2
2 files changed, 7 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_type_check.py b/numpy/lib/tests/test_type_check.py
index 8b990c57e..a89d6ce7f 100644
--- a/numpy/lib/tests/test_type_check.py
+++ b/numpy/lib/tests/test_type_check.py
@@ -270,5 +270,11 @@ class test_real_if_close(NumpyTestCase):
b = real_if_close(a+1e-7j,tol=1e-6)
assert_all(isrealobj(b))
+class test_array_conversion(NumpyTestCase):
+ def check_asfarray(self):
+ a = asfarray(array([1,2,3]))
+ assert_equal(a.__class__,ndarray)
+ assert issubdtype(a.dtype,float)
+
if __name__ == "__main__":
NumpyTest().run()
diff --git a/numpy/lib/type_check.py b/numpy/lib/type_check.py
index 8e10ac2b5..60c84e335 100644
--- a/numpy/lib/type_check.py
+++ b/numpy/lib/type_check.py
@@ -46,7 +46,7 @@ def asfarray(a, dtype=_nx.float_):
dtype = _nx.obj2sctype(dtype)
if not issubclass(dtype, _nx.inexact):
dtype = _nx.float_
- return asanyarray(a,dtype=dtype)
+ return asarray(a,dtype=dtype)
def real(val):
"""Return the real part of val.