diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-01-16 21:32:58 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-01-16 21:32:58 +0000 |
commit | edc8a8542059b76f131d5d32612543d506970a48 (patch) | |
tree | a99192852db331b4dcdb9c5d7801e04427fd81a6 | |
parent | 8b271e09233bdb81d0f4706e1021ca2e5c227fe3 (diff) | |
download | numpy-edc8a8542059b76f131d5d32612543d506970a48.tar.gz |
Fix shape() function. Fix so that longdouble typecode never overwrites double if longdouble is the same as double. Fix missing math module import.
-rw-r--r-- | numpy/core/numeric.py | 1 | ||||
-rw-r--r-- | numpy/core/numerictypes.py | 37 | ||||
-rw-r--r-- | numpy/core/oldnumeric.py | 5 |
3 files changed, 25 insertions, 18 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index d4a23d2f1..c784b7fb9 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -308,6 +308,7 @@ def base_repr (number, base=2, padding=0): """ chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' + import math lnb = math.log(base) res = padding*chars[0] if number == 0: diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index 9455981cb..1955c370a 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -160,23 +160,26 @@ def _add_types(): base, bit, char = bitname(typeobj) revdict[typeobj] = (typeinfo[a][:-1], (base, bit, char), a) if base != '': - allTypes["%s%d" % (base, bit)] = typeobj - typeDict["%s%d" % (base, bit)] = typeobj - if base == 'uint': - tmpstr = 'UInt%d' % bit - typeDict[tmpstr] = typeobj - na_name = tmpstr - elif base == 'complex': - na_num = '%s%d' % (base.capitalize(), bit/2) - elif base == 'bool': - na_name = base.capitalize() - typeDict[na_name] = typeobj - else: - na_name = "%s%d" % (base.capitalize(), bit) - typeDict[na_name] = typeobj - typeNA[na_name] = typeobj - typeNA[typeobj] = na_name - typeNA[typeinfo[a][0]] = na_name + myname = "%s%d" % (base, bit) + if (name != 'longdouble' and name != 'clongdouble') or \ + myname not in allTypes.keys(): + allTypes[myname] = typeobj + typeDict[myname] = typeobj + if base == 'uint': + tmpstr = 'UInt%d' % bit + typeDict[tmpstr] = typeobj + na_name = tmpstr + elif base == 'complex': + na_name = '%s%d' % (base.capitalize(), bit/2) + elif base == 'bool': + na_name = base.capitalize() + typeDict[na_name] = typeobj + else: + na_name = "%s%d" % (base.capitalize(), bit) + typeDict[na_name] = typeobj + typeNA[na_name] = typeobj + typeNA[typeobj] = na_name + typeNA[typeinfo[a][0]] = na_name if char != '': typeDict[char] = typeobj typeNA[char] = na_name diff --git a/numpy/core/oldnumeric.py b/numpy/core/oldnumeric.py index 09f7775f0..863bd36bc 100644 --- a/numpy/core/oldnumeric.py +++ b/numpy/core/oldnumeric.py @@ -311,7 +311,10 @@ def shape(a): """shape(a) returns the shape of a (as a function call which also works on nested sequences). """ - return asarray(a).shape + try: + return a.shape + except AttributeError: + return asarray(a).shape def compress(condition, m, axis=-1): """compress(condition, x, axis=-1) = those elements of x corresponding |