summaryrefslogtreecommitdiff
path: root/numpy/lib/getlimits.py
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2009-01-14 07:56:10 +0000
committerStefan van der Walt <stefan@sun.ac.za>2009-01-14 07:56:10 +0000
commit9837e0234859a4dc0fcbfe1acd8902faeb5a6558 (patch)
tree3b7a631757145417a4781aa0aec326e3559021e6 /numpy/lib/getlimits.py
parent1775a591a73fe76162ea871f07349648620ac5b5 (diff)
downloadnumpy-9837e0234859a4dc0fcbfe1acd8902faeb5a6558.tar.gz
Fix finfo to work on all instances, not just NumPy scalars.
Diffstat (limited to 'numpy/lib/getlimits.py')
-rw-r--r--numpy/lib/getlimits.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/numpy/lib/getlimits.py b/numpy/lib/getlimits.py
index 658549179..ccb0e2b3d 100644
--- a/numpy/lib/getlimits.py
+++ b/numpy/lib/getlimits.py
@@ -88,6 +88,12 @@ class finfo(object):
_finfo_cache = {}
def __new__(cls, dtype):
+ try:
+ dtype = np.dtype(dtype)
+ except TypeError:
+ # In case a float instance was given
+ dtype = np.dtype(type(dtype))
+
obj = cls._finfo_cache.get(dtype,None)
if obj is not None:
return obj
@@ -220,8 +226,11 @@ class iinfo:
_min_vals = {}
_max_vals = {}
- def __init__(self, type):
- self.dtype = np.dtype(type)
+ def __init__(self, int_type):
+ try:
+ self.dtype = np.dtype(int_type)
+ except TypeError:
+ self.dtype = np.dtype(type(int_type))
self.kind = self.dtype.kind
self.bits = self.dtype.itemsize * 8
self.key = "%s%d" % (self.kind, self.bits)
@@ -258,7 +267,7 @@ class iinfo:
def __str__(self):
"""String representation."""
- return '''
+ return '''\
Machine parameters for %(dtype)s
---------------------------------------------------------------------
min = %(min)s