summaryrefslogtreecommitdiff
path: root/numpy/lib/utils.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2008-08-15 21:15:58 +0000
committerTravis Oliphant <oliphant@enthought.com>2008-08-15 21:15:58 +0000
commit65839d74bd0e9402763adb7976cbe86d7beeb0fb (patch)
tree1f91ec0601cb132d05f57c46974fea0ffdaf70f4 /numpy/lib/utils.py
parent73d91a6b903497a7ad38aab97f48e51f21a1e5df (diff)
downloadnumpy-65839d74bd0e9402763adb7976cbe86d7beeb0fb.tar.gz
Re-factor code to remove dependency of numpy.core on numpy.lib by moving issubclass_, issubsctype, and issubdtype to numpy.core.numerictypes
Diffstat (limited to 'numpy/lib/utils.py')
-rw-r--r--numpy/lib/utils.py45
1 files changed, 2 insertions, 43 deletions
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index bb162bfd3..684876591 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -4,7 +4,8 @@ import pkgutil
import types
import re
-from numpy.core.numerictypes import obj2sctype, generic
+from numpy.core.numerictypes import obj2sctype, generic, issubclass_, \
+ issubsctype, issubdtype
from numpy.core.multiarray import dtype as _dtype
from numpy.core import product, ndarray
@@ -14,48 +15,6 @@ __all__ = ['issubclass_', 'get_numpy_include', 'issubsctype',
'get_include', 'info', 'source', 'who', 'lookfor',
'byte_bounds', 'may_share_memory', 'safe_eval']
-def issubclass_(arg1, arg2):
- try:
- return issubclass(arg1, arg2)
- except TypeError:
- return False
-
-def issubsctype(arg1, arg2):
- return issubclass(obj2sctype(arg1), obj2sctype(arg2))
-
-def issubdtype(arg1, arg2):
- """
- Returns True if first argument is a typecode lower/equal in type hierarchy.
-
- Parameters
- ----------
- arg1 : dtype_like
- dtype or string representing a typecode.
- arg2 : dtype_like
- dtype or string representing a typecode.
-
-
- See Also
- --------
- numpy.core.numerictypes : Overview of numpy type hierarchy.
-
- Examples
- --------
- >>> np.issubdtype('S1', str)
- True
- >>> np.issubdtype(np.float64, np.float32)
- False
-
- """
- if issubclass_(arg2, generic):
- return issubclass(_dtype(arg1).type, arg2)
- mro = _dtype(arg2).type.mro()
- if len(mro) > 1:
- val = mro[1]
- else:
- val = mro[0]
- return issubclass(_dtype(arg1).type, val)
-
def get_include():
"""
Return the directory that contains the numpy \\*.h header files.