diff options
author | Travis Oliphant <oliphant@enthought.com> | 2005-09-29 08:29:28 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2005-09-29 08:29:28 +0000 |
commit | b953386c9f25892725f200e2da947a317ff22625 (patch) | |
tree | 3459694ffb0dc85321b8b56ad6bee52bb459f6b7 /scipy/base/getlimits.py | |
parent | a287aa7a0964ffb6bf5ccb19f940c9d36e99daf1 (diff) | |
download | numpy-b953386c9f25892725f200e2da947a317ff22625.tar.gz |
Simplified scalar type checking.
Diffstat (limited to 'scipy/base/getlimits.py')
-rw-r--r-- | scipy/base/getlimits.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/scipy/base/getlimits.py b/scipy/base/getlimits.py index c8287ed57..6445e1b28 100644 --- a/scipy/base/getlimits.py +++ b/scipy/base/getlimits.py @@ -14,13 +14,21 @@ def frz(a): a = a.reshape((1,)) return a +_convert_to_float = { + numeric.csingle: numeric.single, + numeric.acomplex: numeric.afloat, + numeric.clongfloat: numeric.longfloat + } + _machar_cache = {} class finfo(object): def __init__(self, dtype): dtype = numeric.obj2dtype(dtype) + if not issubclass(dtype, numeric.inexact): + raise ValueError, "data type not inexact" if not issubclass(dtype, numeric.floating): - raise ValueError, "data type not a float" + dtype = _convert_to_float[dtype] if dtype is numeric.afloat: try: self.machar = _machar_cache[numeric.afloat] @@ -56,10 +64,15 @@ class finfo(object): "point number") _machar_cache[numeric.longfloat] = self.machar - for word in ['epsilon', 'tiny', 'precision', 'resolution']: + for word in ['tiny', 'precision', 'resolution', + 'ngrd','maxexp','minexp','epsneg','negep', + 'machep']: setattr(self,word,getattr(self.machar, word)) self.max = self.machar.huge self.min = -self.max + self.eps = self.machar.epsilon + self.nexp = self.machar.iexp + self.nmant = self.machar.it if __name__ == '__main__': f = finfo(numeric.single) |