Created originally on Bitbucket by Serge Matyunin (Sergey Matyunin)
Changesets for this Pull Request have not been imported, because it had been already declined on Bitbucket. Marked as closed by the import user.
- In W_Broadcast (micronumpy) implemented nd and iters attributes, reset method.
- W_Broadcast is rewritten using W_FlatIterator for implementation of iters attribute.
- W_FlatIterator gets optional arguments in constructor, added reset method
Now implementation of broadcast seems complete.
Known problem: broadcast of broadcast doesn't work properly. The following code from test_numeric.py in numpy fails on the second loop iteration:
def test_broadcast_in_args(self): # gh-5881 arrs = [np.empty((6, 7)), np.empty((5, 6, 1)), np.empty((7,)), np.empty((5, 1, 7))] mits = [np.broadcast(*arrs), np.broadcast(np.broadcast(*arrs[:2]), np.broadcast(*arrs[2:])), np.broadcast(arrs, np.broadcast(*arrs[1:-1]), arrs[-1])] for mit in mits: assert_equal(mit.shape, (5, 6, 7)) assert_equal(mit.nd, 3) assert_equal(mit.numiter, 4) for a, ia in zip(arrs, mit.iters): assert_(a is ia.base)
It means np.broadcast(np.broadcast(*arrs[:2]), np.broadcast(*arrs[2:])) doesn't work.
I will try to fix it in another PR.