summaryrefslogtreecommitdiff
path: root/scipy/base/getlimits.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2005-09-29 03:26:24 +0000
committerTravis Oliphant <oliphant@enthought.com>2005-09-29 03:26:24 +0000
commitdfe6c48f254c71d3752532ab870f2aced8717ca2 (patch)
tree5fd10adfdbdf555c676e10ae00009d7be43abe62 /scipy/base/getlimits.py
parent8c8881a825c8ac9b1c6f8f3e1bce9ee84c3caa6a (diff)
downloadnumpy-dfe6c48f254c71d3752532ab870f2aced8717ca2.tar.gz
No pre-computing limits in getlimits.py
Diffstat (limited to 'scipy/base/getlimits.py')
-rw-r--r--scipy/base/getlimits.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/scipy/base/getlimits.py b/scipy/base/getlimits.py
index 839f45dee..c8287ed57 100644
--- a/scipy/base/getlimits.py
+++ b/scipy/base/getlimits.py
@@ -14,13 +14,7 @@ def frz(a):
a = a.reshape((1,))
return a
-_machar_cache = {numeric.afloat: \
- MachAr(lambda v:array([v],'d'),
- lambda v:frz(v.astype('i'))[0],
- lambda v:array(frz(v)[0],'d'),
- lambda v:'%24.16e' % array(frz(v)[0],'d'),
- 'scipy float precision floating point number')
- }
+_machar_cache = {}
class finfo(object):
def __init__(self, dtype):
@@ -28,7 +22,17 @@ class finfo(object):
if not issubclass(dtype, numeric.floating):
raise ValueError, "data type not a float"
if dtype is numeric.afloat:
- self.machar = _machar_cache[numeric.afloat]
+ try:
+ self.machar = _machar_cache[numeric.afloat]
+ except KeyError:
+ self.machar = MachAr(lambda v:array([v],'d'),
+ lambda v:frz(v.astype('i'))[0],
+ lambda v:array(frz(v)[0],'d'),
+ lambda v:'%24.16e' % array(frz(v)[0],'d'),
+ 'scipy float precision floating point '\
+ 'number')
+ _machar_cache[numeric.afloat] = self.machar
+
elif dtype is numeric.single:
try:
self.machar = _machar_cache[numeric.single]