Anonymous avatar Anonymous committed 5a8fc96

add more tests

Comments (0)

Files changed (2)

pypy/module/micronumpy/interp_numarray.py

                 n_old_elems_to_use *= old_shape[oldI]
             if n_new_elems_used == n_old_elems_to_use:
                 oldI += 1
-                if oldI >= len(old_shape):
-                    break
-                cur_step = steps[oldI]
-                n_old_elems_to_use *= old_shape[oldI]
+                if oldI < len(old_shape):
+                    cur_step = steps[oldI]
+                    n_old_elems_to_use *= old_shape[oldI]
     elif order == 'C':
         for i in range(len(old_shape) - 1, -1, -1):
             steps.insert(0, old_strides[i] / last_step)
                 n_old_elems_to_use *= old_shape[oldI]
             if n_new_elems_used == n_old_elems_to_use:
                 oldI -= 1
-                if oldI < -len(old_shape):
-                    break
-                cur_step = steps[oldI]
-                n_old_elems_to_use *= old_shape[oldI]
+                if oldI >= -len(old_shape):
+                    cur_step = steps[oldI]
+                    n_old_elems_to_use *= old_shape[oldI]
+    assert len(new_strides) == len(new_shape)
     return new_strides
 
 class BaseArray(Wrappable):

pypy/module/micronumpy/test/test_numarray.py

         assert calc_new_strides([2, 3, 4], [8, 3], [1, 16], 'F') is None
         assert calc_new_strides([24], [2, 4, 3], [48, 6, 1], 'C') is None
         assert calc_new_strides([24], [2, 4, 3], [24, 6, 2], 'C') == [2]
+        assert calc_new_strides([105, 1], [3, 5, 7], [35, 7, 1],'C') == [1, 1]
+        assert calc_new_strides([1, 105], [3, 5, 7], [35, 7, 1],'C') == [105, 1]
+        assert calc_new_strides([1, 105], [3, 5, 7], [35, 7, 1],'F') is None
+        assert calc_new_strides([1, 1, 1, 105, 1], [15, 7], [7, 1],'C') == \
+                                    [105, 105, 105, 1, 1]
+        assert calc_new_strides([1, 1, 105, 1, 1], [7, 15], [1, 7],'F') == \
+                                    [1, 1, 1, 105, 105]
 
 
 class AppTestNumArray(BaseNumpyAppTest):
         assert (a[:, 1, :].sum(1) == [70, 315, 560]).all()
         raises (ValueError, 'a[:, 1, :].sum(2)')
         assert ((a + a).T.sum(2).T == (a + a).sum(0)).all()
-        skip("Those are broken, fix after removing Scalar")
         assert (a.reshape(1,-1).sum(0) == range(105)).all()
         assert (a.reshape(1,-1).sum(1) == 5460)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.