Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r44906:0981805b0f24
Date: 2011-06-13 07:56 -0700
http://bitbucket.org/pypy/pypy/changeset/0981805b0f24/
Log: Added signature tests for slicing.
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
@@ -84,7 +84,7 @@
return self.get_concrete().descr_len(space)
def descr_getitem(self, space, w_idx):
- # TODO: indexation by tuples
+ # TODO: indexing by tuples
start, stop, step, slice_length = space.decode_index4(w_idx,
self.find_size())
if step == 0:
# Single index
@@ -93,7 +93,6 @@
# Slice
res = SingleDimSlice(start, stop, step, slice_length, self,
self.signature.transition(SingleDimSlice.static_signature))
return space.wrap(res)
-
@unwrap_spec(item=int, value=float)
def descr_setitem(self, space, item, value):
@@ -233,7 +232,7 @@
def descr_len(self, space):
return space.wrap(self.find_size())
-
+
def calc_index(self, item):
raise NotImplementedError
diff --git a/pypy/module/micronumpy/test/test_base.py
b/pypy/module/micronumpy/test/test_base.py
--- a/pypy/module/micronumpy/test/test_base.py
+++ b/pypy/module/micronumpy/test/test_base.py
@@ -17,3 +17,13 @@
assert v2.signature is v3.signature
v4 = ar.descr_add(space, ar)
assert v1.signature is v4.signature
+
+ def test_slice_signature(self, space):
+ ar = SingleDimArray(10)
+ v1 = ar.descr_getitem(space, space.wrap(slice(1, 5, 1)))
+ v2 = ar.descr_getitem(space, space.wrap(slice(4, 6, 1)))
+ assert v1.signature is v2.signature
+
+ v3 = ar.descr_add(space, v1)
+ v4 = ar.descr_add(space, v2)
+ assert v3.signature is v4.signature
\ No newline at end of file
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit