summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-06-12 20:24:52 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-06-12 20:24:52 +0000
commitc0d32936d1991a2cd8a75b21b805777c18be66e9 (patch)
treeecc4dd875730f526c8c4eddd22d7bb71eadabd3a /numpy/lib
parent844fd39844d3930ffa9c98c7d569b1f9829671ff (diff)
downloadnumpy-c0d32936d1991a2cd8a75b21b805777c18be66e9.tar.gz
Apply patch #137
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/function_base.py6
-rw-r--r--numpy/lib/index_tricks.py29
2 files changed, 18 insertions, 17 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 5e36f2d07..934f7da33 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -13,12 +13,12 @@ __all__ = ['logspace', 'linspace',
import types
import numpy.core.numeric as _nx
from numpy.core.numeric import ones, zeros, arange, concatenate, array, \
- asarray, empty, empty_like, asanyarray
+ asarray, empty, empty_like, asanyarray, ndarray
from numpy.core.numeric import ScalarType, dot, where, newaxis
from numpy.core.umath import pi, multiply, add, arctan2, \
frompyfunc, isnan, cos, less_equal, sqrt, sin, mod, exp
from numpy.core.oldnumeric import ravel, nonzero, choose, \
- typecodes, ArrayType, sort
+ typecodes, sort
from numpy.lib.shape_base import atleast_1d
from numpy.lib.twodim_base import diag
from _compiled_base import digitize, bincount, _insert, add_docstring
@@ -148,7 +148,7 @@ def average(a, axis=0, weights=None, returned=False):
else:
raise ValueError, 'averaging weights have wrong shape'
- if not isinstance(d, ArrayType):
+ if not isinstance(d, ndarray):
if d == 0.0:
raise ZeroDivisionError, 'zero denominator in average()'
if returned:
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py
index 13a45498a..c659c7584 100644
--- a/numpy/lib/index_tricks.py
+++ b/numpy/lib/index_tricks.py
@@ -124,7 +124,7 @@ class nd_grid(object):
def __getitem__(self,key):
try:
size = []
- typecode = _nx.Int
+ typ = int
for k in range(len(key)):
step = key[k].step
start = key[k].start
@@ -132,17 +132,18 @@ class nd_grid(object):
if step is None: step=1
if type(step) is type(1j):
size.append(int(abs(step)))
- typecode = _nx.Float
+ typ = float
else:
size.append(int((key[k].stop - start)/(step*1.0)))
- if isinstance(step,types.FloatType) or \
- isinstance(start, types.FloatType) or \
- isinstance(key[k].stop, types.FloatType):
- typecode = _nx.Float
+ if isinstance(step, float) or \
+ isinstance(start, float) or \
+ isinstance(key[k].stop, float):
+ typ = float
if self.sparse:
- nn = map(lambda x,t: _nx.arange(x,dtype=t),size,(typecode,)*len(size))
+ nn = map(lambda x,t: _nx.arange(x, dtype=t), size, \
+ (typ,)*len(size))
else:
- nn = _nx.indices(size,typecode)
+ nn = _nx.indices(size, typ)
for k in range(len(size)):
step = key[k].step
start = key[k].start
@@ -169,7 +170,7 @@ class nd_grid(object):
length = int(step)
step = (key.stop-start)/float(step-1)
stop = key.stop+step
- return _nx.arange(0,length,1,_nx.Float)*step + start
+ return _nx.arange(0, length,1, float)*step + start
else:
return _nx.arange(start, stop, step)
@@ -204,18 +205,18 @@ class concatenator(object):
self.col = 0
def __getitem__(self,key):
- if isinstance(key,types.StringType):
+ if isinstance(key, str):
frame = sys._getframe().f_back
mymat = matrix.bmat(key,frame.f_globals,frame.f_locals)
return mymat
- if type(key) is not types.TupleType:
+ if type(key) is not tuple:
key = (key,)
objs = []
scalars = []
final_dtypedescr = None
for k in range(len(key)):
scalar = False
- if type(key[k]) is types.SliceType:
+ if type(key[k]) is slice:
step = key[k].step
start = key[k].start
stop = key[k].stop
@@ -227,7 +228,7 @@ class concatenator(object):
newobj = function_base.linspace(start, stop, num=size)
else:
newobj = _nx.arange(start, stop, step)
- elif type(key[k]) is types.StringType:
+ elif type(key[k]) is str:
if (key[k] in 'rc'):
self.matrix = True
self.col = (key[k] == 'c')
@@ -236,7 +237,7 @@ class concatenator(object):
self.axis = int(key[k])
continue
except:
- raise ValueError, "Unknown special directive."
+ raise ValueError, "unknown special directive"
elif type(key[k]) in ScalarType:
newobj = asarray([key[k]])
scalars.append(k)