summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2017-08-06 17:22:20 -0500
committerGitHub <noreply@github.com>2017-08-06 17:22:20 -0500
commit91b06c021319faccb008a8ee485d26ae227bf079 (patch)
tree7195085d6bcaec87b5f2f0629c14456fcfa53d11 /numpy/lib
parentf307cec3962926558b6387ebb4ab8d3f4ea3aa34 (diff)
parent351fe979580ab842cc5c04e1b616d3a64936a695 (diff)
downloadnumpy-91b06c021319faccb008a8ee485d26ae227bf079.tar.gz
Merge pull request #9522 from eric-wieser/stop-using-obj2sctype
BUG: Fix problems with obj2sctype
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/tests/test_type_check.py8
-rw-r--r--numpy/lib/type_check.py3
2 files changed, 8 insertions, 3 deletions
diff --git a/numpy/lib/tests/test_type_check.py b/numpy/lib/tests/test_type_check.py
index e05079981..8945b61ea 100644
--- a/numpy/lib/tests/test_type_check.py
+++ b/numpy/lib/tests/test_type_check.py
@@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function
import numpy as np
from numpy.compat import long
from numpy.testing import (
- assert_, assert_equal, assert_array_equal, run_module_suite
+ assert_, assert_equal, assert_array_equal, run_module_suite, assert_raises
)
from numpy.lib.type_check import (
common_type, mintypecode, isreal, iscomplex, isposinf, isneginf,
@@ -422,5 +422,11 @@ class TestArrayConversion(object):
assert_equal(a.__class__, np.ndarray)
assert_(np.issubdtype(a.dtype, np.floating))
+ # previously this would infer dtypes from arrays, unlike every single
+ # other numpy function
+ assert_raises(TypeError,
+ asfarray, np.array([1, 2, 3]), dtype=np.array(1.0))
+
+
if __name__ == "__main__":
run_module_suite()
diff --git a/numpy/lib/type_check.py b/numpy/lib/type_check.py
index b2de153d3..e6aae8ddd 100644
--- a/numpy/lib/type_check.py
+++ b/numpy/lib/type_check.py
@@ -98,8 +98,7 @@ def asfarray(a, dtype=_nx.float_):
array([ 2., 3.])
"""
- dtype = _nx.obj2sctype(dtype)
- if not issubclass(dtype, _nx.inexact):
+ if not _nx.issubdtype(dtype, _nx.inexact):
dtype = _nx.float_
return asarray(a, dtype=dtype)