[pypy-commit] pypy numpy-multidim: add test_repr for 3-dim array
mattip
noreply at buildbot.pypy.org
Mon Oct 31 23:23:48 CET 2011
Author: mattip
Branch: numpy-multidim
Changeset: r48635:6adc66bed4bc
Date: 2011-11-01 00:19 +0200
http://bitbucket.org/pypy/pypy/changeset/6adc66bed4bc/
Log: add test_repr for 3-dim array
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -671,9 +671,9 @@
if ndims>2:
ret += '['
for i in range(self.shape[0]):
- ret += NDimSlice(self.parent, self.signature, [(i,0,0,1)], self.shape[1:]).tostr(commai,indent=indent+' ')
+ ret += NDimSlice(self.parent, self.signature, [(i,0,0,1)], self.shape[1:]).tostr(comma,indent=indent+' ')
if i+1<self.shape[0]:
- ret += ',\n\n'
+ ret += ',\n\n'+ indent
ret += ']'
elif ndims==2:
ret += '['
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -71,6 +71,14 @@
assert repr(a) == '''array([[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0]])'''
+ a = zeros((2,3,4))
+ assert repr(a) == '''array([[[0.0, 0.0, 0.0, 0.0],
+ [0.0, 0.0, 0.0, 0.0],
+ [0.0, 0.0, 0.0, 0.0]],
+
+ [[0.0, 0.0, 0.0, 0.0],
+ [0.0, 0.0, 0.0, 0.0],
+ [0.0, 0.0, 0.0, 0.0]]])'''
def test_repr_slice(self):
from numpy import array, zeros
@@ -200,6 +208,10 @@
a[1:4:2] = 0.
assert a[1] == 0.
assert a[3] == 0.
+ def test_scalar(self):
+ from numpy import array
+ a = array(3)
+ assert a[0] == 3
def test_len(self):
from numpy import array
More information about the pypy-commit
mailing list