summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/arrayprint.py2
-rw-r--r--numpy/core/einsumfunc.py2
-rw-r--r--numpy/core/numeric.py6
-rw-r--r--numpy/core/records.py4
-rw-r--r--numpy/core/shape_base.py12
-rw-r--r--numpy/core/tests/test_ufunc.py2
6 files changed, 14 insertions, 14 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index 349f8ea39..318ad5495 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -331,7 +331,7 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ',
# skip over array(
next_line_prefix += " "*len(prefix)
- lst = _formatArray(a, format_function, len(a.shape), max_line_width,
+ lst = _formatArray(a, format_function, a.ndim, max_line_width,
next_line_prefix, separator,
_summaryEdgeItems, summary_insert)[:-1]
return lst
diff --git a/numpy/core/einsumfunc.py b/numpy/core/einsumfunc.py
index 0b15c213b..c54a4a263 100644
--- a/numpy/core/einsumfunc.py
+++ b/numpy/core/einsumfunc.py
@@ -360,7 +360,7 @@ def _parse_einsum_input(operands):
if operands[num].shape == ():
ellipse_count = 0
else:
- ellipse_count = max(len(operands[num].shape), 1)
+ ellipse_count = max(operands[num].ndim, 1)
ellipse_count -= (len(sub) - 3)
if ellipse_count > longest:
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index d4d4045a0..896ad7f6a 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -1354,9 +1354,9 @@ def tensordot(a, b, axes=2):
a, b = asarray(a), asarray(b)
as_ = a.shape
- nda = len(a.shape)
+ nda = a.ndim
bs = b.shape
- ndb = len(b.shape)
+ ndb = b.ndim
equal = True
if na != nb:
equal = False
@@ -1461,7 +1461,7 @@ def roll(a, shift, axis=None):
else:
broadcasted = broadcast(shift, axis)
- if len(broadcasted.shape) > 1:
+ if broadcasted.ndim > 1:
raise ValueError(
"'shift' and 'axis' should be scalars or 1D sequences")
shifts = {ax: 0 for ax in range(a.ndim)}
diff --git a/numpy/core/records.py b/numpy/core/records.py
index 91b70614c..7ad0c111a 100644
--- a/numpy/core/records.py
+++ b/numpy/core/records.py
@@ -613,8 +613,8 @@ def fromarrays(arrayList, dtype=None, shape=None, formats=None,
shape = shape[:-nn]
for k, obj in enumerate(arrayList):
- nn = len(descr[k].shape)
- testshape = obj.shape[:len(obj.shape) - nn]
+ nn = descr[k].ndim
+ testshape = obj.shape[:obj.ndim - nn]
if testshape != shape:
raise ValueError("array-shape mismatch in array %d" % k)
diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py
index 58b0dcaac..22ed17836 100644
--- a/numpy/core/shape_base.py
+++ b/numpy/core/shape_base.py
@@ -49,7 +49,7 @@ def atleast_1d(*arys):
res = []
for ary in arys:
ary = asanyarray(ary)
- if len(ary.shape) == 0:
+ if ary.ndim == 0:
result = ary.reshape(1)
else:
result = ary
@@ -99,9 +99,9 @@ def atleast_2d(*arys):
res = []
for ary in arys:
ary = asanyarray(ary)
- if len(ary.shape) == 0:
+ if ary.ndim == 0:
result = ary.reshape(1, 1)
- elif len(ary.shape) == 1:
+ elif ary.ndim == 1:
result = ary[newaxis,:]
else:
result = ary
@@ -163,11 +163,11 @@ def atleast_3d(*arys):
res = []
for ary in arys:
ary = asanyarray(ary)
- if len(ary.shape) == 0:
+ if ary.ndim == 0:
result = ary.reshape(1, 1, 1)
- elif len(ary.shape) == 1:
+ elif ary.ndim == 1:
result = ary[newaxis,:, newaxis]
- elif len(ary.shape) == 2:
+ elif ary.ndim == 2:
result = ary[:,:, newaxis]
else:
result = ary
diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py
index f7b66f90c..8a5e7f603 100644
--- a/numpy/core/tests/test_ufunc.py
+++ b/numpy/core/tests/test_ufunc.py
@@ -1013,7 +1013,7 @@ class TestUfunc(TestCase):
MyThing.getitem_count += 1
if not isinstance(i, tuple):
i = (i,)
- if len(i) > len(self.shape):
+ if len(i) > self.ndim:
raise IndexError("boo")
return MyThing(self.shape[len(i):])